xionhack Posted December 23, 2009 Share Posted December 23, 2009 Hello. Im pulling a date from mysql, but when i give it the ]date('F j Y', $date) format it outputs december 31st, 1969. If i dont try to give it the format, it outputs the correct date. Can somebody tell me what am i doing wrong? thanks! Link to comment https://forums.phpfreaks.com/topic/186115-php-and-mysql-december-31st-1969/ Share on other sites More sharing options...
.josh Posted December 23, 2009 Share Posted December 23, 2009 what format is $date ? probably date does not recognize the format you are using. Link to comment https://forums.phpfreaks.com/topic/186115-php-and-mysql-december-31st-1969/#findComment-982872 Share on other sites More sharing options...
xionhack Posted December 23, 2009 Author Share Posted December 23, 2009 $date is a value that i got from a mysql database and is date data field Link to comment https://forums.phpfreaks.com/topic/186115-php-and-mysql-december-31st-1969/#findComment-982880 Share on other sites More sharing options...
rajivgonsalves Posted December 23, 2009 Share Posted December 23, 2009 the second parameter for date is a timestamp so you can try date('F j Y', strtotime($date)); Link to comment https://forums.phpfreaks.com/topic/186115-php-and-mysql-december-31st-1969/#findComment-982881 Share on other sites More sharing options...
xionhack Posted December 23, 2009 Author Share Posted December 23, 2009 still hgibves me the same result... Link to comment https://forums.phpfreaks.com/topic/186115-php-and-mysql-december-31st-1969/#findComment-982891 Share on other sites More sharing options...
rajivgonsalves Posted December 23, 2009 Share Posted December 23, 2009 echo $date and tell us what you see Link to comment https://forums.phpfreaks.com/topic/186115-php-and-mysql-december-31st-1969/#findComment-982893 Share on other sites More sharing options...
.josh Posted December 23, 2009 Share Posted December 23, 2009 what is the actual date? Is it a pre-1970 or post-2038 date? Link to comment https://forums.phpfreaks.com/topic/186115-php-and-mysql-december-31st-1969/#findComment-982906 Share on other sites More sharing options...
Deoctor Posted December 23, 2009 Share Posted December 23, 2009 give some sample values of the string $date is it like this 20091205 20081125 Link to comment https://forums.phpfreaks.com/topic/186115-php-and-mysql-december-31st-1969/#findComment-982909 Share on other sites More sharing options...
Deoctor Posted December 23, 2009 Share Posted December 23, 2009 try like this echo date("F j Y", strtotime("20080130")) if this gives correctly then try replacing the 20080130 with $date Link to comment https://forums.phpfreaks.com/topic/186115-php-and-mysql-december-31st-1969/#findComment-982915 Share on other sites More sharing options...
dbradbury Posted December 23, 2009 Share Posted December 23, 2009 have you pulled the required info needed? like all the rows? with post_time and such.. as im trying to publish what im about to show you to my website, but my server's ftp is updating lol so i cant test it and tweak it lol well my code is: <?php include("connect.php"); $getnews = mysql_query("SELECT * FROM phpbb_posts WHERE forum_id='4' ORDER BY post_time DESC"); $checknews = mysql_num_rows($getnews); if($checknews==0) { echo 'No news as of yet!'; } else { while($row = mysql_fetch_assoc($getnews)) { $date = date('g:ia - D jS M', strtotime($row['post_time'])); echo '<tr><td>'.$row['post_subject'].'</td><td>'.$date.'</td></tr><br> <tr><td>'.nl2br($row['post_text']).'</td></tr>'; } } ?> please beware that this is obviously used for myself to my spec, hope it can help in anyway maybe... Link to comment https://forums.phpfreaks.com/topic/186115-php-and-mysql-december-31st-1969/#findComment-983126 Share on other sites More sharing options...
dbradbury Posted December 23, 2009 Share Posted December 23, 2009 my server came back on, and i uploaded my code, and that worked! Link to comment https://forums.phpfreaks.com/topic/186115-php-and-mysql-december-31st-1969/#findComment-983362 Share on other sites More sharing options...
xionhack Posted December 24, 2009 Author Share Posted December 24, 2009 Sorry! It was my bad. I had the wrong variable. Its working now with strotime($date) Link to comment https://forums.phpfreaks.com/topic/186115-php-and-mysql-december-31st-1969/#findComment-983458 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.