refiking Posted August 13, 2010 Share Posted August 13, 2010 OK. So, I am getting a date with the date in m/d/y format and then the hour and the minute. How can I convert this the correct way. This is what I am currently trying: $started = date("Y-m-d H:i:s", strtotime($_POST['started'] . ' ' . $_POST['started_hour'] . ': ' . $_POST['started_min'])); echo $started; It give me the standard "1969-12-31 17:00:00". When all I tried was $_POST['started'], I at least got the date right. Link to comment https://forums.phpfreaks.com/topic/210668-help-with-converting-a-date/ Share on other sites More sharing options...
Rifts Posted August 13, 2010 Share Posted August 13, 2010 I think you need to change this part date("Y-m-d H:i:s") use this is format it how u want http://php.net/manual/en/function.date.php Link to comment https://forums.phpfreaks.com/topic/210668-help-with-converting-a-date/#findComment-1098974 Share on other sites More sharing options...
PFMaBiSmAd Posted August 13, 2010 Share Posted August 13, 2010 You have an extra space after the : inside the strtotime() part that is throwing off the expected format. Link to comment https://forums.phpfreaks.com/topic/210668-help-with-converting-a-date/#findComment-1098977 Share on other sites More sharing options...
refiking Posted August 13, 2010 Author Share Posted August 13, 2010 Same response $started = date("Y-m-d H:i:s", strtotime($_POST['started'] . ' ' . $_POST['started_hour'] . ' : ' . $_POST['started_min'])); Link to comment https://forums.phpfreaks.com/topic/210668-help-with-converting-a-date/#findComment-1098978 Share on other sites More sharing options...
PFMaBiSmAd Posted August 13, 2010 Share Posted August 13, 2010 What would adding a space before the : have to do with removing the extra one that is after the : that is causing the problem??? Link to comment https://forums.phpfreaks.com/topic/210668-help-with-converting-a-date/#findComment-1098979 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.