View Full Version : DATETIME -> time()
12-04-2003, 10:03 AM
In the mysql database I'm currently working on, there's a DATETIME field which has the format 0000-00-00 00:00:00. How can I convert that to have the same format as time(), so I can do calculations with the DATETIME field using the time()-function?
12-04-2003, 02:47 PM
if you mean PHP time(); (eg a unix timestamp) , you can
"SELECT UNIX_TIMESTAMP('your_date_ field') as unixtime FROM $table"
else if you mean mysql's built in date juggling functions any valid MySQL timestamp type can be munged with the inbuilt MySQL date handling functions, you don't need to convert them.
If you can get MySQL to do the date arithmetic for you then do so as its much faster!
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.