Skip to content

Date archive for: July 2013

Tired of dealing with Leap Years? Use DateTime::diff()

Doing this the old-fashioned way was pretty complex. It was bad enough when a normal February would mess up your math, you also had to take leap years into account. Using the DateTime functions in php >= 5.3 lets you think about your business case, not calendars.

Don’t take my word for it! **Test it**!

For more info see the php docs: http://php.net/manual/en/datetime.diff.php