Jump to content

convert DATE to TIME in field


jasonc

Recommended Posts

the site has been completely redone and it now stores the date and time in this format so to make things easy i wanted to keep the same format throughout, and all the other entries that i have copied over from the old database had the old formated date/time so now none of these entries show up on the site at all because of it.

 

all i want to do is convert them and remove the old formated date field once done.

I hope your mysql timezone is set correctly and that your mysql timezone/DST database is up to date or you will mess up all your data. I also hope you don't have any dates older than 1970 or plan to use dates later than 2038, because the mysql Unix Timestamp storage and the mysql conversion functions currently only work for that range of years.

 

You took a huge step backwards by going from dates stored as fixed human readable values (i.e. a date/time stored as 2012-01-07 08:39:00 will always be that value) to Unix Timestamps, which are dependent on a relatively slow and ambiguous conversion. Converting a Unix Timestamp to its human readable value is dependent on the timezone setting and any DST offset and is affected by how up to date the timezone/DST database is - mysql and php each have their own timezone/DST database that must be kept up to date as locations have been redefining their DST start/stop dates.

 

Using Unix Timestamps for your data storage also means that you cannot use any day/month/year grouping directly in any queries, so you must execute more/slower queries to manipulate data that is associated with any human readable day/month/year divisions.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.