marknt Posted October 21, 2006 Share Posted October 21, 2006 Hello people i need some help. Im figuring this out.I have a variable $var="11 PM". I want to convert it into military time like this one ---> 23here is my code but its not working:[code]$var = "10"; // this is equivalent to 10 PM$military_time = date('H', $var);echo "Hour: $var<br>";echo "Military time: $military_time<br>";[/code]Please help thanks a lot!Cheers Link to comment https://forums.phpfreaks.com/topic/24631-hep-pleasechanging-10-pm-to-military-time/ Share on other sites More sharing options...
alpine Posted October 21, 2006 Share Posted October 21, 2006 [quote]$var = "10"; // this is equivalent to 10 PM[/quote]If your $var IS 10 it's not equivalent to 10 PM.... how does your full time format look like?Just the number "10" is nothing to work width in formatting time. Link to comment https://forums.phpfreaks.com/topic/24631-hep-pleasechanging-10-pm-to-military-time/#findComment-112194 Share on other sites More sharing options...
marknt Posted October 21, 2006 Author Share Posted October 21, 2006 Hello sir alpine. I think i solved my own problem *sigh* :DI think im just lucky ;DHere is my code:[code]// this is a string$mytime = "11:30 PM";// Converting string time ( 11:30 PM ) to Military time (23:30)$temp = strtotime("$mytime");$military_time = date('H:i', $temp);echo "String Time: $mytime<br>";echo "Temp: $temp<br>";echo "Military time: $military_time<br>";[/code]Thank you for replying Sir Alpine.Cheers Link to comment https://forums.phpfreaks.com/topic/24631-hep-pleasechanging-10-pm-to-military-time/#findComment-112199 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.