Click here to Skip to main content
16,018,234 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,

I need a help on timestamp compare wherein I have a timestamp time2=2013/04/06T13:24:00Z and I want to compare this with current timestamp. I need this comparision to check if the time is less then 10 minutes.

if ((time1-time2)<600)
{
echo 'valid time';
//do some stuff
}
else
{
echo 'time expired';
}

Here time1 will be current timestamp and time2 will be my given timestamp and I am taking 600 as 10 minutes.

Is there any way to compare timestamp for this type of format...Please suggest if you know

Thankyou.
Posted

1 solution

Pretty good article - Comparing Dates in PHP[^].
 
Share this answer
 
Comments
Thomas Daniels 6-Apr-13 5:05am    
+5!
Phionix11 6-Apr-13 6:44am    
Its good article but It did'nt work for me. I want to check time whether the incoming request is within 10 minutes range. so that i can know that request is older so expired.
fuiboo 18-Apr-13 19:34pm    
That's a perfectly fine answer to your question.
The improtant part in the link is the "strtotime" function.
That function converts your 2013/04/06T13:24:00Z timestamp to a UNIX-Timestamp which is easier to compare to topical time() the way you want it to do.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900