davr davr - 1 year ago 60
PHP Question

Simplest way to increment a date in PHP?

Say I have a string coming in,

, what's the simplest code I could write to turn that into
? Right now I'm just using
, then adding
, then using
, but just wondering if there is a cleaner, simpler, or more clever way of doing it.

Answer Source

A clean way is to use strtotime()

$date = strtotime("+1 day", strtotime("2007-02-28"));
echo date("Y-m-d", $date);

Will give you the 2007-03-01