Jump to content

Recommended Posts

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>.";
 
 
 
?>
Link to comment
https://forums.phpfreaks.com/topic/294732-converting-date-string-to-date/
Share on other sites

It's a timestamp.  I just don't know how to incorporate it into my current code.

 

Did you try that query format that Barand provided? It should return the value in a formatted string: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_from-unixtime

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.