tags:

views:

58

answers:

2

I have a unix timestamp that I would like to convert using mysql if possible. I'd like to have:

Mon. May 21st 2009

I can of course do this with PHP but why if I can have the database do it. Does a function exist for this?

Thanks.

+8  A: 

You can look at FROM_UNIXTIME()

mysql> SELECT FROM_UNIXTIME(1196440219);
    -> '2007-11-30 10:30:19'
mysql> SELECT FROM_UNIXTIME(1196440219) + 0;
    -> 20071130103019.000000
mysql> SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(), '%Y %D %M %h:%i:%s %x');
    -> '2007 30th November 10:30:59 2007'

To see what specifier you can use, there's a table at this location.

Ólafur Waage
Thank you Ólafur! I couldn't find anything on it. Thanks for pointing me in the right direction.
jim
You're welcome.
Ólafur Waage
Thank you again Ólafur. That example helped me greatly. :)
jim
+3  A: 

Look here. It's called FROM_UNIXTIME.

mkluwe
Thank you mkluwe.
jim