I have two dates in the format below:
Start Date = 30-10-2009
End Date = 30-11-2009
How, with PHP could I calculate the seconds between these two dates?
I have two dates in the format below:
Start Date = 30-10-2009
End Date = 30-11-2009
How, with PHP could I calculate the seconds between these two dates?
The function strtotime()
will convert a date to a unix-style timestamp (in seconds). You should then be able to subtract the end date from the start date to get the difference.
$difference_secs = strtotime($end_date) - strtotime($start_date);
Parse the two dates into Unix timestamps using strtotime
, then get the difference:
$firstTime = strtotime("30-10-2009");
$secondTime = strtotime("30-11-2009");
$diff = $secondtime - $firstTime;