unrelenting Posted August 18, 2008 Share Posted August 18, 2008 I need to convert these date formats to what's after the equal sign so that I can import them into a date column in mysql. It won't take them as they are. Some of the dates go back to the 1800's so I can't use timestamps which is what I prefer.... 9/5/1992 = 1992-09-05 12/15/1876 = 1876-12-15 etc.. Link to comment https://forums.phpfreaks.com/topic/120131-date-conversion/ Share on other sites More sharing options...
iversonm Posted August 18, 2008 Share Posted August 18, 2008 a timestamp can be negative, thats how you use it for dates before Jan 01 1970 Link to comment https://forums.phpfreaks.com/topic/120131-date-conversion/#findComment-618889 Share on other sites More sharing options...
unrelenting Posted August 18, 2008 Author Share Posted August 18, 2008 a timestamp can be negative, thats how you use it for dates before Jan 01 1970 I know but I need the formula to convert it to the YYYY-MM-DD format. Link to comment https://forums.phpfreaks.com/topic/120131-date-conversion/#findComment-618890 Share on other sites More sharing options...
iversonm Posted August 18, 2008 Share Posted August 18, 2008 well do something like this $timestamp=whatever your timestamp is that is in your database or were ever you are storing them $newtime=date('Y-M-d', $timestamp); Link to comment https://forums.phpfreaks.com/topic/120131-date-conversion/#findComment-618896 Share on other sites More sharing options...
unrelenting Posted August 18, 2008 Author Share Posted August 18, 2008 well do something like this $timestamp=whatever your timestamp is that is in your database or were ever you are storing them $newtime=date('Y-M-d', $timestamp); They aren't timestamps. They are formatted like the date on the left of the equal sign up above. The timestamp only works on dates after 1970. Most of mine are before that so I needed to convert them without moving them to the timestamp format. Anyway, I got it done in Excel fairly easily so I don't need this conversion anymore but I was curious how it could be done. Link to comment https://forums.phpfreaks.com/topic/120131-date-conversion/#findComment-618901 Share on other sites More sharing options...
PFMaBiSmAd Posted August 18, 2008 Share Posted August 18, 2008 http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_str-to-date Link to comment https://forums.phpfreaks.com/topic/120131-date-conversion/#findComment-618909 Share on other sites More sharing options...
unrelenting Posted August 18, 2008 Author Share Posted August 18, 2008 http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_str-to-date So what would the query look like? Link to comment https://forums.phpfreaks.com/topic/120131-date-conversion/#findComment-618912 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.