LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Translating output of MySQL -> English (https://www.linuxquestions.org/questions/programming-9/translating-output-of-mysql-english-293669/)

benrose111488 02-22-2005 10:14 PM

Translating output of MySQL -> English
 
Okay, I have a table called ENTRIES, and to get the date, I'm using the code:

PHP Code:

$result mysql_query("SELECT `TIMEPOSTED` FROM `ENTRIES` WHERE `ID`='".$x."'");
$row mysql_fetch_row($result);
$timeposted=$row[0]; 

to retrieve the time a blog entry was made. Now, this usually outputs something funky like "2005-02-22 13:15:26"

Can I translate this into "February 2, 2005 1:15 PM" somehow?

And furthermore, If I were to make a query so people could select what month they'd want to see entries from, could I write a good query to find that?

marghorp 02-23-2005 12:56 AM

To translate a date use this:

$timeposted = date("d.m.Y \a\t H:i:s ",strtotime($row[0]));

This will reformat the timestamp variable and make it in any kind you want. See www.php.net for details on the date function. d=day, m=month, Y=year, H=hour in 24 hour format, and so on. See www.php.net for details.


All times are GMT -5. The time now is 08:08 AM.