Jump to content

PHP help: AM PM Issue


srijon

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.