I have the following date:
$data = date("Y-d-m H:i:s");
I need to create the following date:
$data_expira = date("Y-d-m H:i:s"); // adicionando +24h
How can I add + 1d to the current date?
I have the following date:
$data = date("Y-d-m H:i:s");
I need to create the following date:
$data_expira = date("Y-d-m H:i:s"); // adicionando +24h
How can I add + 1d to the current date?
As of PHP 5.2.0, there is a simple way to work with dates and times, with the class DateTime
- returns a new DateTime object
$date = new DateTime('+1 day');
echo $date->format('Y-m-d H:i:s');
Another way: ideone result
$amanha = date("Y-d-m H:i:s", time() + 86400);
echo $amanha;
Another way: ideone result
$amanha = date('Y-m-d H:i:s', strtotime('+1 days'));
echo $amanha;
For local time use date_default_timezone_set
- set the default time zone used by all date and time functions in a script
Ideone example with date_default_timezone_set ("America/Sao_Paulo");