emartin24 Posted May 31, 2007 Share Posted May 31, 2007 Hello, I have a date that's in DATE_RFC822 format: Thu, 31 May 2007 18:16:55 EDT I want to store it in a MySQL table as a TIMESTAMP. When I try to do a strtotime on the value and insert it, I get an 'Incorrect datetime value' error for the column. I also would like to have it be a PST value, but I guess I can just convert it when I retrieve it from the DB. Any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/53802-formatting-date-to-store-in-mysql-table/ Share on other sites More sharing options...
Caesar Posted May 31, 2007 Share Posted May 31, 2007 What you making the column? INT? DATE? Just make the column INT...and strtotime() it. Quote Link to comment https://forums.phpfreaks.com/topic/53802-formatting-date-to-store-in-mysql-table/#findComment-265921 Share on other sites More sharing options...
Caesar Posted May 31, 2007 Share Posted May 31, 2007 I just tested your formatted date string on my Linux server..works fine. <?php $str = strtotime('Thu, 31 May 2007 18:16:55 EDT'); $newtime = date("M d, Y", $str); print($newtime); print($str); /* Returns: May 31, 2007 1180649815 */ ?> Quote Link to comment https://forums.phpfreaks.com/topic/53802-formatting-date-to-store-in-mysql-table/#findComment-265924 Share on other sites More sharing options...
Caesar Posted May 31, 2007 Share Posted May 31, 2007 I also would like to have it be a PST value, but I guess I can just convert it when I retrieve it from the DB. Yes...format it only after you retrieve it. It's best to store it as a pure timestamp. Quote Link to comment https://forums.phpfreaks.com/topic/53802-formatting-date-to-store-in-mysql-table/#findComment-265926 Share on other sites More sharing options...
emartin24 Posted June 1, 2007 Author Share Posted June 1, 2007 What you making the column? INT? DATE? Just make the column INT...and strtotime() it. I was trying it with DATE, TIMESTAMP, etc., but changing it to INT is what I needed Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/53802-formatting-date-to-store-in-mysql-table/#findComment-265937 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.