Web Hosting Talk







View Full Version : GMT MySQL Timestamp


ballingtonma
03-26-2004, 09:42 PM
Hi,
I have a column that is a timestamp so as soon as a new row is added it inserts the current date.

It is formated like: 20040326114906
And i break it up by doing:
$joined = $row["joined"];
$day = substr("$joined", 6, 2);
$month = substr("$joined", 4, 2);
$year = substr("$joined", 0, 4);
$hour = substr("$joined", 8, 2);
$min = substr("$joined", 10, 2);
$sec = substr("$joined", 12, 2);
$joined = "$day $month $year, $hour:$min:$sec";

But, i was wandering if there was an easier way to do it and also in GMT time.

Thanks is advance,
Matt

gromy
03-26-2004, 10:03 PM
MySQL
--------------------
SELECT DATE_FORMAT(sysdate(), '%d %m %Y, %H:%i:%s') FROM `table_name` LIMIT 1;

Normal SQL
--------------------
SELECT TO_CHAR(sysdate, 'DD MM YYYY, HH24:MI:SS') FROM dual;

http://www.mysql.com/doc/en/Date_and_time_functions.html

ballingtonma
03-27-2004, 04:18 PM
Thanks, but is there a way to do it without using a mysql query, and also set the timestamp into GMT time or transform it from the server time as it is originaly stamped into GMT?