Jump to content

[SOLVED] Subtracting Dates


Bendude14

Recommended Posts

If you are not to do it SQL, then you can do it by converting both dates to a timestamp, then deduct then convert into days.

 

example:

 

<?php
$date1 = '2008-02-05';
$date2 = '2008-03-05';
$secsInDay = 60 * 60 * 24;

$secsInterval = strtotime($date2) - strtotime($date1);
$daysInterval = $secsInterval / $secsInDay;

echo $daysInterval;
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.