Porl123 Posted October 30, 2008 Share Posted October 30, 2008 Hi people, I'm not sure whether this might be a mysql problem but I'm hoping you can help me anyway. I've got a news page where time stamps are recorded using the NOW() function in mysql, but every time I echo it back it's off completely date('D, d F', $date) is what I'm using to format it and Wed, 31 December is what it returns. Anyone know why? Thanks Link to comment https://forums.phpfreaks.com/topic/130702-solved-php-date/ Share on other sites More sharing options...
Mchl Posted October 30, 2008 Share Posted October 30, 2008 What do you mean by 'it's off completely'? You get different date, than you think you should? Usual way of getting dates from mysql is echo date('D, d F', strtotime($dateFromMysql)); Link to comment https://forums.phpfreaks.com/topic/130702-solved-php-date/#findComment-678264 Share on other sites More sharing options...
MasterACE14 Posted October 30, 2008 Share Posted October 30, 2008 or like this... <?php $datetime = $row['date']; $year = substr( $datetime, 0, 4 ); $mon = substr( $datetime, 4, 2 ); $day = substr( $datetime, 6, 2 ); $hour = substr( $datetime, 8, 2 ); $min = substr( $datetime, 10, 2 ); $sec = substr( $datetime, 12, 2 ); $orgdate = date("F j, Y", mktime( $hour, $min, $sec, $mon, $day, $year ) ); echo $orgdate; ?> Link to comment https://forums.phpfreaks.com/topic/130702-solved-php-date/#findComment-678265 Share on other sites More sharing options...
Porl123 Posted October 30, 2008 Author Share Posted October 30, 2008 Ah, that's done it :] thanks guys Link to comment https://forums.phpfreaks.com/topic/130702-solved-php-date/#findComment-678267 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.