Results 1 to 3 of 3
Thread: Formatting date/time from mySQL
Oct 8, 2007, 05:26 #1
Formatting date/time from mySQL
I have a datetime field in a mysql database. By default it is formatted as Y-m-d H:i:s.
When I query the database for the date, I would like to reformat it before displaying it in the browser. I would like to write it like:
This page was last updated at H:i on d-m-Y
How can I do this please?
Oct 8, 2007, 06:02 #2
- Join Date
- Sep 2006
- College Station, TX
- 0 Post(s)
- 0 Thread(s)
you have a couple options
1) use the mysql function date_format to format the column in the select query like thisCode:
select date_format(your_col, '%H:%i on %d-%m-%Y') as your_col_formatted from your_tableCode:
select unix_timestamp(your_col) unix_timestamp_of_your_col from your_tablePHP Code:
$date = date('H:i on d-m-y', $row['unix_timestap_of_your_col']);
Oct 8, 2007, 09:58 #3
Excellent! Cheers jcarouth!