-2

I have this code to check if the mysql timestamp is 24 hours old, it works for one string however I need to check two strings but i'm not sure how to add it in

if(strtotime($dateFrom." + 24 hours") <= strtotime("now"))

for example i'd like to add the string in

if(strtotime($dateFrom **&& $dateTo.**" + 24 hours") <= strtotime("now"))
Marc Howard
  • 3
  • 1
  • 5
  • That doesn't really make sense .. which timestamp has to be 24 hours old? The "From" or the "To?" – Explosion Pills Feb 02 '12 at 20:22
  • You dont have the right approach to this. Anyways, when comparing time I always try my best to stick to Unix timestamps. Then you can do $ts - (60 * 60 * 24); for 24 hours ago. – Adam Fowler Feb 03 '12 at 00:33

2 Answers2

1
    if(strtotime($dateFrom." + 24 hours") <= strtotime("now") && 
       strtotime($dateTo." + 24 hours") <= strtotime("now"))
Headshota
  • 21,021
  • 11
  • 61
  • 82
0
if( strtotime($dateFrom + "24 hours") <= strtotime("now") &&
    strtotime($dateTo + "24 hours")   <= strtotime("now"))

OR

if( strtotime($dateFrom + "24 hours") <= strtotime("now") ||
    strtotime($dateTo + "24 hours")   <= strtotime("now"))
Tango Bravo
  • 3,221
  • 3
  • 22
  • 44