srijon Posted April 9, 2011 Share Posted April 9, 2011 I have written the following PHP script. It is working ok but I having problem with the AM and PM issue here. My script cannot differentiate AM and PM. Please help me.. Thanks in Advance <?php $d=("1:01 AM"); if ($d < "2:00 PM") echo "Present"; elseif ($d > "2:00") echo "Late"; elseif ($d == "2:00") echo "Equal"; else echo "Have a nice day!"; ?> Link to comment https://forums.phpfreaks.com/topic/233221-php-help-am-pm-issue/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 9, 2011 Share Posted April 9, 2011 Those are formatted strings and the only way you can compare formatted strings is if each string has exactly the same format. You would need to use 24hr format with two hour digits (you would need the leading zero) in order for your comparisons to work. Link to comment https://forums.phpfreaks.com/topic/233221-php-help-am-pm-issue/#findComment-1199394 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.