bluedogatdingdong Posted July 26, 2004 Share Posted July 26, 2004 I am trying to list a diary of events on my web site. The date format is MySql is yyyy/mm/dd - 2004/07/26 I need to reformat the field on the web page to Monday 26 July 2004 for example I've found all the variables to reformat is straight PHP speak ie "l j F Y" I've tried <?php echo date ("l j F Y", ($row_Recordset1['date'])); ?> but this returns Thursday 1 January 1970, which wasn't at all what I was expecting. So what is the syntax to format the required field? <?php echo $row_Recordset1['Date']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/1902-date-formatting/ Share on other sites More sharing options...
morpheus.100 Posted July 30, 2004 Share Posted July 30, 2004 Easy. Get the 40 extra server formats extention from big mac's and install. Drag date from applications panel onto page then use the available server formats in application panel listed in a dropdown beside the date record. Quote Link to comment https://forums.phpfreaks.com/topic/1902-date-formatting/#findComment-6205 Share on other sites More sharing options...
morpheus.100 Posted July 30, 2004 Share Posted July 30, 2004 And if you cant find it pm me. I'll post it. Quote Link to comment https://forums.phpfreaks.com/topic/1902-date-formatting/#findComment-6206 Share on other sites More sharing options...
morpheus.100 Posted July 30, 2004 Share Posted July 30, 2004 I've tried <?php echo date ("l j F Y", ($row_Recordset1['date'])); ?> but this returns Thursday 1 January 1970, which wasn't at all what I was expecting. This format is incorrect for the date you require. To get a true result you need to use strtotime like below with correct letters for your format. <?php echo date('l, d F, Y',strtotime($row_Recordset1['date_added'])); ?> Without the strtotime is UNIX format, but to format mySQL use the above. You will find this format produces :- Day(test) Date(leading zero) Month(text) Long year Thursday, 29 July, 2004 Quote Link to comment https://forums.phpfreaks.com/topic/1902-date-formatting/#findComment-6207 Share on other sites More sharing options...
CrystalSkull Posted July 30, 2004 Share Posted July 30, 2004 Or you can format the date in the SQL query itself. Example - $query = "SELECT title, post, author, DATE_FORMAT(date_entered, '%W, %M %D, %Y') AS postdate"; That would format the SQL date to the format you want. Then when you want to display it you would use postdate instead of the row name the timestamp is in. Make sense? -Mark B) Quote Link to comment https://forums.phpfreaks.com/topic/1902-date-formatting/#findComment-6208 Share on other sites More sharing options...
bluedogatdingdong Posted August 17, 2004 Author Share Posted August 17, 2004 Thanks for all your replies - I used the SQL option in the end. I should have known, I done it once before, and forgot! Quote Link to comment https://forums.phpfreaks.com/topic/1902-date-formatting/#findComment-6262 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.