JSHINER Posted July 28, 2008 Share Posted July 28, 2008 Mon Jul 28 04:16:22 +0000 2008 What is this date format and how can I get it to display different ways? Like say: "Monday, July 28, 2008 at 4:16 pm" Quote Link to comment https://forums.phpfreaks.com/topic/117022-date-format-mon-jul-28-041622-0000-2008-what-is-this/ Share on other sites More sharing options...
Nhoj Posted July 28, 2008 Share Posted July 28, 2008 got any code we can take a look at? Maybe some code that is used to display the date. Quote Link to comment https://forums.phpfreaks.com/topic/117022-date-format-mon-jul-28-041622-0000-2008-what-is-this/#findComment-601875 Share on other sites More sharing options...
JSHINER Posted July 28, 2008 Author Share Posted July 28, 2008 It's from the Twitter API - I just echo $date; Quote Link to comment https://forums.phpfreaks.com/topic/117022-date-format-mon-jul-28-041622-0000-2008-what-is-this/#findComment-601877 Share on other sites More sharing options...
Tandem Posted July 28, 2008 Share Posted July 28, 2008 Check out the date function on php.net, there's a table of different formats. date("jS M", time()) for example would return "28th Jul". Quote Link to comment https://forums.phpfreaks.com/topic/117022-date-format-mon-jul-28-041622-0000-2008-what-is-this/#findComment-601879 Share on other sites More sharing options...
JSHINER Posted July 28, 2008 Author Share Posted July 28, 2008 I know about the date function, however I need what I have to be recognized as a standard date format. Quote Link to comment https://forums.phpfreaks.com/topic/117022-date-format-mon-jul-28-041622-0000-2008-what-is-this/#findComment-601881 Share on other sites More sharing options...
obsidian Posted July 28, 2008 Share Posted July 28, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/117022-date-format-mon-jul-28-041622-0000-2008-what-is-this/#findComment-601886 Share on other sites More sharing options...
revraz Posted July 28, 2008 Share Posted July 28, 2008 How is that, since it isn't a "standard" date format. Put it into an array and then make it a format. Explode it on the spaces. Quote Link to comment https://forums.phpfreaks.com/topic/117022-date-format-mon-jul-28-041622-0000-2008-what-is-this/#findComment-601887 Share on other sites More sharing options...
JSHINER Posted July 28, 2008 Author Share Posted July 28, 2008 That is displaying the time four hours ahead (5:38pm instead of 1:38pm) - how can I fix that? Quote Link to comment https://forums.phpfreaks.com/topic/117022-date-format-mon-jul-28-041622-0000-2008-what-is-this/#findComment-601906 Share on other sites More sharing options...
wildteen88 Posted July 28, 2008 Share Posted July 28, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/117022-date-format-mon-jul-28-041622-0000-2008-what-is-this/#findComment-601912 Share on other sites More sharing options...
corbin Posted July 28, 2008 Share Posted July 28, 2008 To reformat the date they gave you just do: $date = "Mon Jul 28 04:16:22 +0000 2008"; echo date(<params>, strtotime($date)); That doesn't appear to be a standard date format, but I bet strtotime can still parse it. Quote Link to comment https://forums.phpfreaks.com/topic/117022-date-format-mon-jul-28-041622-0000-2008-what-is-this/#findComment-601916 Share on other sites More sharing options...
JSHINER Posted July 28, 2008 Author Share Posted July 28, 2008 The date is from the Twitter API - no idea what format it is or why they use it. My server is in the same timezone as I and it's just pulling the time from $date Quote Link to comment https://forums.phpfreaks.com/topic/117022-date-format-mon-jul-28-041622-0000-2008-what-is-this/#findComment-601918 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.