un-sure how to convert this

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
Sevengraff
Forum Contributor
Posts: 232
Joined: Thu Apr 25, 2002 9:34 pm
Location: California USA
Contact:

un-sure how to convert this

Post by Sevengraff »

I have a bunch of records that use the MySQL date field (YYYY-MM-DD). I need to change this into a standard UNIX timestamp, because I'm trying to convert old entries from my old script into the new one. Is there a way to do this?
User avatar
cactus
Forum Regular
Posts: 343
Joined: Tue Jun 10, 2003 4:16 am
Location: UK

Post by cactus »

Do you want the database entires to have a timet ?

If not, convert it when you get it out of the database, else you will need to write a script to loop through the database and convert the old format to the new, ensuring that you use "update" in your SQL.

Regards,
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You can use MySQL time and date functions to manipulate the info:
http://www.mysql.com/doc/en/Date_and_ti ... tions.html
(check out UNIX_TIMESTAMP())

Mac
User avatar
Sevengraff
Forum Contributor
Posts: 232
Joined: Thu Apr 25, 2002 9:34 pm
Location: California USA
Contact:

Post by Sevengraff »

UNIX_TIMESTAMP() worked perfectly. Thanks a bunch!
Post Reply