Page 1 of 1
date_format
Posted: Fri Feb 18, 2005 7:33 am
by Jim_Bo
Hi,
Can you add gmt +9 on a statement like so?
Code: Select all
date_format(date, '%d/%m/%y %r') as date,
Thanks
Posted: Fri Feb 18, 2005 7:35 am
by n00b Saibot
use strtotime()
Posted: Sat Feb 19, 2005 4:34 am
by Jim_Bo
Hey,
Should something like this work .. to add 14 hours to the date/time that was input using now() held in the database:
Code: Select all
SELECT id, date_format('%d/%m/%y %r', date_add(date, interval 14 hours)) as date, ...
Thanks
Posted: Sat Feb 19, 2005 4:49 am
by n00b Saibot
Have YOU tried this.
Posted: Sat Feb 19, 2005 5:08 am
by Jim_Bo
Hi
Do you mean have I tried it .. ?
Yer it gives a check syntax error ..
Posted: Sat Feb 19, 2005 5:29 am
by n00b Saibot
Yer it gives a check syntax error ..

PHP way
Code: Select all
//suppose $date contains db stored date
//then reqd. date will be
$reqdDate = strtotime($date . " + 14 hours " );
and for MySQL remove 's' from hours as there is no hours only H O U R

Posted: Sat Feb 19, 2005 7:16 am
by Jim_Bo
Hi,
I got it .. here is the code im sure it will come in handy for people .. clean way to add/subtract GMT and display the date and time in a nice formated result ..
Sql code:
Code: Select all
SELECT id, DATE_FORMAT(ADDDATE(date, INTERVAL 18 HOUR), '%d-%b-%Y %r') AS date, ..
Thanks