How Do I convert from a Time() to a DATE as YYYY-m-d h:i:s

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
beckwiga
Forum Newbie
Posts: 9
Joined: Wed Sep 21, 2005 7:45 pm

How Do I convert from a Time() to a DATE as YYYY-m-d h:i:s

Post by beckwiga »

I'm using phpBB. The user_regdate is stored as time(), I think in GMT?

ex: 11691162602

I'm trying to convert back from this to a date that I can use in a normal DATETIME field, YYYY-m-d h:i:s.

ex: 2007-02-27 xx:xx:xx or whatever it is.

Any advice appreciated.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If memory serves, the time stamp is the server's native. If that's GMT, then it's GMT. If that's PST, then it's PST.

The MySQL function FROM_UNIXTIME() will convert it to a date-time formatted string.
beckwiga
Forum Newbie
Posts: 9
Joined: Wed Sep 21, 2005 7:45 pm

Post by beckwiga »

Yup, that works. That's exactly what I needed, thanks.
Post Reply