XJTRy Posted November 29, 2012 Share Posted November 29, 2012 Think title says it all. I want to take a html form input (0845) and covert it time format for PHP/MySQL (08:45:00). The seconds will always default to 00. Even if I convert the input to (string), the zero is a problem. $input = (string)845 // echos 845 $input= (string)0845// echos 0 Ultimately, I simply wish to echo so I end up with an ("Y-m-d H:m:s") format. $day = date("Y-m-d") . $input; Link to comment https://forums.phpfreaks.com/topic/271351-convert-form-input-into-time/ Share on other sites More sharing options...
TOA Posted November 29, 2012 Share Posted November 29, 2012 you want strtotime() Link to comment https://forums.phpfreaks.com/topic/271351-convert-form-input-into-time/#findComment-1396198 Share on other sites More sharing options...
XJTRy Posted November 29, 2012 Author Share Posted November 29, 2012 I've tried. $input = (string)0845; $convert_input = strtotime($input); echo $convert_input; Returns nothing. Link to comment https://forums.phpfreaks.com/topic/271351-convert-form-input-into-time/#findComment-1396208 Share on other sites More sharing options...
XJTRy Posted November 29, 2012 Author Share Posted November 29, 2012 Figured out by simply removing zero. Essentially, 8AM should be sent as "8" not "08". Link to comment https://forums.phpfreaks.com/topic/271351-convert-form-input-into-time/#findComment-1396217 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.