Jump to content

Date In The Middle Between To Dates


levyta

Recommended Posts

php > $s = strtotime('2012-01-01');
php > $e = strtotime('2013-01-01');
php > echo date('Y-m-d', ($s + $e)/2);
2012-07-02

Note that your math is wrong. 7/2 is halfway through the year, not 7/1. Months are not all the same length.

 

Also, this probably won't work right on 32-bit systems.

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.