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! Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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)); Quote Link to comment Share on other sites More sharing options...
xionhack Posted December 23, 2009 Author Share Posted December 23, 2009 still hgibves me the same result... Quote Link to comment 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 Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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... Quote Link to comment 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! Quote Link to comment 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) Quote Link to comment 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.