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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.