broheem Posted December 31, 2007 Share Posted December 31, 2007 I'm trying to format a date which is pulled from MySQL. I have a couple of record sets being looped through. All of them use the following code: echo date('M m, y', strtotime($result['date'])); The first record set displays the correctly formatted date. But the last one doesn't display the correct date instead it's stuck on on 'Dec 12, 07'. The values for the last data set are (when outputted without formatting): 2007-12-13 15:23:48 2007-12-31 07:06:01 So the values are coming through correctly but when I add the code above to format them they get switch to displaying 'Dec 12, 07' for both. Am I doing something wrong here? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/83843-solved-date-formatting-discrepancy/ Share on other sites More sharing options...
AndyB Posted December 31, 2007 Share Posted December 31, 2007 http://ca.php.net/manual/en/function.date.php You probably want M j, y not M m, y Quote Link to comment https://forums.phpfreaks.com/topic/83843-solved-date-formatting-discrepancy/#findComment-426717 Share on other sites More sharing options...
Barand Posted December 31, 2007 Share Posted December 31, 2007 That's because 'M m y' is MonthName MonthNumber Year Quote Link to comment https://forums.phpfreaks.com/topic/83843-solved-date-formatting-discrepancy/#findComment-426718 Share on other sites More sharing options...
broheem Posted December 31, 2007 Author Share Posted December 31, 2007 Wow, I'm an idiot. I knew it must have been something simple. It's odd I didn't catch on with the others... they were trivial dates so I when they appeared to be displaying correctly I assumed they were. Thanks for the quick reply! Take care, Happy New Year. Quote Link to comment https://forums.phpfreaks.com/topic/83843-solved-date-formatting-discrepancy/#findComment-426720 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.