Jump to content

preg_match a specific timestamp


neuroxik

Recommended Posts

Alright everyone,

 

So I'm stuck on the one, especially because I've never really took the time to learn regex's correctly, but here's my problem if anyone's willing to help.

 

2011-03-04T18:40:12-05:00

The above line is the kind of line I want to find with preg_match(), this is what I tried (among many variations of it for the past 45 minutes)

 

$tests['xmls_ts'] = "2011-03-04T18:40:12-05:00";
//$xmls_pattern = "/([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2})[0-9]{2})\[0-9]{2})\[0-9]{2})-([0-9]{2})\[0-9]{2})/";
$xmls_pattern = "/(d{4})-(d{2})-(d{2})T(d{2}{2}{2}-d{2}{2})/";
$fd = preg_match($xmls_pattern,$tests['xmls_ts'],$matches); 
if($fd) { echo 'yes'; }
else { echo 'no'; }

 

Can anyone tell me where I'm going wrong?

Link to comment
https://forums.phpfreaks.com/topic/231030-preg_match-a-specific-timestamp/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.