Page 1 of 1
Returning a MySQL date field type
Posted: Wed Jul 13, 2005 4:43 am
by TheOracle
Hi All,
I have a field in a MySQL database with a type of DATE.
This quite obviously stores the date in it, but I want to return the value held in this field in a different format to the one it is held in.
Is there some function for this within PHP?
Many thanks
Re: Returning a MySQL date field type
Posted: Wed Jul 13, 2005 4:45 am
by harrisonad
TheOracle wrote:I want to return the value held in this field in a different format to the one it is held in.
In english please.
Posted: Wed Jul 13, 2005 4:50 am
by phpScott
check out
http://dev.mysql.com/doc/mysql/en/date- ... tions.html in the mysq manaul.
You can output the date in any format you like.
Re: Returning a MySQL date field type
Posted: Wed Jul 13, 2005 5:01 am
by anjanesh
TheOracle wrote:
Is there some function for this within PHP?
Many thanks
PHP Functions.
date()
strtotime()
But I think the MySQL Date functions are better and faster.
Posted: Wed Jul 13, 2005 6:43 am
by TheOracle
thanks guys.
I have used the MySQL DATE_FORMAT function in the select
Posted: Wed Jul 13, 2005 10:02 am
by pickle
Probably the most useful MySQL method would be UNIX_TIMESTAMP(). This'll convert a MySQL timestamp string into its equivalent UNIX timestamp, right in the query. You can then use PHP's date() function to change that into any date representation you like.