Padgoi Posted April 16, 2010 Share Posted April 16, 2010 I'm trying to pull a date from my mysql database. I'm pulling the info correctly but it's showing as a timestamp (string of numbers). How do I get it to display in the correct date format? Here's the snippet: echo "<font color='blue'>The last topic posted in is</font><a href='".$INFO['board_url']."/index.php?showtopic=".$lastpost[1]."&view=findpost&p=".$lastpost[0]."'><font color='red'>".$topics[0]."</font></a><font color='blue'>by</font><a href='".$INFO['board_url']."/index.php?showuser=".$lastpost[3]."'><font color='red'>".$lastpost[2]."</font></a><font color='blue'>in</font><a href='".$INFO['board_url']."/index.php?showtopic=".$lastpost[1]."&view=findpost&p=".$lastpost[0]."'><font color='red'>".$z[0]."</font></a>at <font color='red'>".$lastpost[4]."</font>"; The very last part ".$lastpost[4]." is the timestamp portion. How do I get that to show correctly? The query that is pulling the data from the dbase is: $q = "SELECT pid, topic_id, LEFT(author_name, 15), author_id, post_date from ibf_posts order by pid desc limit 1"; where post_date is the timestamp. Any help would be greatly appreciated! Link to comment https://forums.phpfreaks.com/topic/198790-help-with-timestamp/ Share on other sites More sharing options...
F1Fan Posted April 16, 2010 Share Posted April 16, 2010 Use the strtotime() function. This will convert the timestamp to a PHP time stamp, as in the time() function. Then, use the date() function to format it as you wish. http://www.w3schools.com/php/php_ref_date.asp Link to comment https://forums.phpfreaks.com/topic/198790-help-with-timestamp/#findComment-1043342 Share on other sites More sharing options...
fenway Posted April 17, 2010 Share Posted April 17, 2010 STR_TO_DATE() works too. Link to comment https://forums.phpfreaks.com/topic/198790-help-with-timestamp/#findComment-1043724 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.