Jump to content

PHP Time function


lewel

Recommended Posts

Hi I am trying to write a function that determines if an hour is between other two. let me explain myself

 

say I have 10:45 AM as starting time and 3:30 PM as end time and then I have 8:15 AM and I want to determine if lets say 8:15 AM is between 10:45 AM and 3:30 PM How would I do that in PHP? any Ideas?

 

Thanks in advance.

 

I am trying to write a calendar by the way.

 

 

Link to comment
https://forums.phpfreaks.com/topic/91490-php-time-function/
Share on other sites

Hey that worked flawlessly thanks alot I was wondering though if I assign 1 to AM and 0 to PM and I add the start time I add the end time and I add the middle time and then compare would I obtain the same result. Let me explain myself

$start_time= 10+45+1
$middle_time= 8+15+1
$end_time= 3+30+0


if (($middle_time > $start_time) && ($middle_time < $end_time))
    echo "Between <br />";
else
    echo "Outside <br />";

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/91490-php-time-function/#findComment-468669
Share on other sites

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.