how can I make a conditional statement like if date("Y-m-d h:i:s"); is more than 30 seconds after date("Y-m-d h:i:s");.
I've previously used something like date("Y-m-d h:i:s"); < date("Y-m-d h:i:s"); + 30, however this doesn't seem to work.
Help?
how can I make a conditional statement like if date("Y-m-d h:i:s"); is more than 30 seconds after date("Y-m-d h:i:s");.
I've previously used something like date("Y-m-d h:i:s"); < date("Y-m-d h:i:s"); + 30, however this doesn't seem to work.
Help?
Use strtotime()
to convert them to UNIX time.
E.g.:
if(strtotime($date2) - strtotime($date1) > 30) {
// $date2 is more than 30 seconds after $date1
}
or
if(abs(strtotime($date2) - strtotime($date1)) > 30) {
// $dates are more than 30 second apart
}