Jump to content

Date Format - Mon Jul 28 04:16:22 +0000 2008 - What is this?


JSHINER

Recommended Posts

That isn't really a defined code format at all, but you may be able to parse it (although, the time provided would be 4:15am). Try something like this:

<?php
$ts = 'Mon Jul 28 04:16:22 +0000 2008';
if (preg_match('|^([a-z]{3})\s([a-z]{3})\s(\d+)\s(\d+\:\d+\:\d+)\s\+\d+\s(\d{4})$|i', $ts, $match))
{
  $str = "$match[1] $match[2] $match[3], $match[5] $match[4]";
  echo date('l, F j, Y \a\t g:i a', strtotime($str));
}
?>

 

Hope this helps.

Where are you running the code from? From your website? If so, the server your site is hosted on is most probably in a different timezone than you. The date/time PHP outputs is in relation to the servers timezone.

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.