Page 1 of 1

How to format a DateTime MySql Field ?

Posted: Thu Jun 12, 2003 5:33 am
by tintin
Hi,

After having fetched a TimeStamp field, I can perform some computations and display it with something like : date ( $format, $row[0] );

But I can't find how to do the same with a DateTime. Should I convert it before and how ?

I would like to avoid the workaround to select from the database both the value, and the Mysql formatted value.

Thanks for help.

Posted: Thu Jun 12, 2003 6:57 am
by twigletmac
MySQL has some handy Date and Time functions:
http://www.mysql.com/doc/en/Date_and_ti ... tions.html

For formatting for display I tend to use DATE_FORMAT(), if, however, I'm going to need to manipulate the date once it's been extracted then UNIX_TIMESTAMP() comes in handy.

Mac