jeff5656 Posted November 19, 2009 Share Posted November 19, 2009 I have a date of birth field: If I enter a dte before 12/31/69, for instance 12/1/55: When I do this $_POST['dob'] I get 12/1/55, but when I do this: $dob = date("Y-m-d", strtotime($_POST['dob'])); echo "dob is ".$dob; I get 12/31/69. Can mysql not store dates before 1969? Link to comment https://forums.phpfreaks.com/topic/182196-cant-store-a-date-before-123169/ Share on other sites More sharing options...
Mchl Posted November 19, 2009 Share Posted November 19, 2009 MySQL can (use DATE) Problem is with strtotime which converts string to unix timestamp http://en.wikipedia.org/wiki/Unix_time You have to use something different to convert your dates, if you want to work on pre 1970 dates Link to comment https://forums.phpfreaks.com/topic/182196-cant-store-a-date-before-123169/#findComment-961359 Share on other sites More sharing options...
jeff5656 Posted November 19, 2009 Author Share Posted November 19, 2009 When you say something different, what are you referring to? how do I do convert $_POST[dob] to pre-1970 values? Link to comment https://forums.phpfreaks.com/topic/182196-cant-store-a-date-before-123169/#findComment-961360 Share on other sites More sharing options...
Mchl Posted November 19, 2009 Share Posted November 19, 2009 For example use explode to convert your date to an array, then create a string from resultant array that will have YYYY-MM-DD format. Link to comment https://forums.phpfreaks.com/topic/182196-cant-store-a-date-before-123169/#findComment-961372 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.