sradha
03-10-2010, 04:54 PM
Hello....I want to compare whether the current time is between 2 time and the code goes like
$curtime=date("h:i:s a");
if(($t1<=$curtime)&&($curtime<=$t2))
{//some code}
else{//code}
here values of $t1 and $t2 are obtained from database.t1 and t2 are obtained in the format like "08:15:00 pm".Using this code and format comparison is ok but problem is in the case with 'am' and 'pm'.It's not possible to compare time based on am and pm.For example if the current time is 10:15:10 pm and $t1=10:09:10 am and $t2=10:25:00 am then 'else loop' should get executed...right??but with this code 'if loop' gets executed...so someone plzzz help me.
$curtime=date("h:i:s a");
if(($t1<=$curtime)&&($curtime<=$t2))
{//some code}
else{//code}
here values of $t1 and $t2 are obtained from database.t1 and t2 are obtained in the format like "08:15:00 pm".Using this code and format comparison is ok but problem is in the case with 'am' and 'pm'.It's not possible to compare time based on am and pm.For example if the current time is 10:15:10 pm and $t1=10:09:10 am and $t2=10:25:00 am then 'else loop' should get executed...right??but with this code 'if loop' gets executed...so someone plzzz help me.