PHP - add 1 day to date format mm-dd-yyyy

date, php

Solution

there you go

$date = "04-15-2013";
$date1 = str_replace('-', '/', $date);
$tomorrow = date('m-d-Y',strtotime($date1 . "+1 days"));

echo $tomorrow;

this will output

04-16-2013

Documentation for both function date strtotime

Problem

``` <?php $date = "04-15-2013"; $date = strtotime($date); $date = strtotime("+1 day", $date); echo date('m-d-Y', $date); ?> ``` This is driving me crazy and seems so simple. I'm pretty new to PHP, but I can't figure this out. The echo returns `01-01-1970`. The $date will be coming from a `POST` in the format `m-d-Y`, I need to add one day and have it as a new variable to be used later. Do I have to convert $date to `Y-m-d`, add 1 day, then convert back to `m-d-Y`? Would I be better off learning how to use `DateTime`?

Original source