Converting timestamp to English formatted time?

Hey all,
So I have this very small script that is simply pulling information from a dbase and displaying it. The problem is the date in the dbase is stored in a string (it looks like 1424375795 or something). I need to convert that number to the date and time. Here’s the code:

<?php 
 
//query the database
$query = mysql_query("SELECT * FROM topics ORDER BY last_post");
 
//fetch the results / convert results into an array
 
WHILE($rows = mysql_fetch_array($query)):
 
$topic_id = $rows['last_post'];
$topic_title = $rows['title'];
$reply_author = $rows['last_poster_name'];
$reply_time = $rows['last_post'];
endwhile;
 
echo "The last post was made in <font color='blue'>$topic_title</font> by <font color='red'>$reply_author</font> at <font color='green'>$reply_time</font>.";
 
 
 
?>

[php]<?php
echo $rows[‘last_post’] = strtotime(‘02/19/2015 10:30 PM’);
$reply_time = date(‘Y-m-d H:i:s’, $rows[‘last_post’]);
echo ‘
’;
echo $reply_time;[/php]

BTW - You’re using obsolete mysql you should be using either mysqli or PDO.

Thanks Strider, that worked.

One more question . . .
how would I go about refreshing this script say every minute automatically?

Sponsor our Newsletter | Privacy Policy | Terms of Service