Lodius2000 Posted June 9, 2008 Share Posted June 9, 2008 Hi i dont know jack about date(), do you? if so please help, I want to parse this time, from a datetime mysql field: 2008-01-25 19:50:00 i want it to say" 7:50 PM on Friday, January 25, 2008 " i wouldnt mind if those days and months were abbreviated, either or the date time is stored in $row['date'] and is running in a foreach loop, here is my stab at it date('H:i A on D F j, Y', $row['timestamp']) thanks for your help and it prints out 19:33 PM 197012 Wed December 31, 1969 dont ask me where it is getting that date, but it is the same in each iteration of the foreach loop Link to comment https://forums.phpfreaks.com/topic/109350-solved-easy-one-if-you-know-date/ Share on other sites More sharing options...
Lodius2000 Posted June 9, 2008 Author Share Posted June 9, 2008 made a couple mistakes above, I got it to print out the date formattd how I like it but it is still printing the 1969 date with every iteration of the foreach loop whats with that new code date('h:i A \o\n D. F j, Y.', $row['timestamp']) thanks Link to comment https://forums.phpfreaks.com/topic/109350-solved-easy-one-if-you-know-date/#findComment-560868 Share on other sites More sharing options...
PFMaBiSmAd Posted June 9, 2008 Share Posted June 9, 2008 Use the mysql date_format() function in your SELECT query to format a datetime field any way you want - http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format The reason your existing code is not working is because the php date() function expects a Unix timestamp as the second parameter - http://php.net/date Link to comment https://forums.phpfreaks.com/topic/109350-solved-easy-one-if-you-know-date/#findComment-560871 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.