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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.