here is my code for the current date time (now):
$my_date_time = date('Y-m-d H:i:s');
how can I add one hour while keeping that format?
You can do this simply with strtotime
function:
$my_date_time = date('Y-m-d H:i:s', strtotime('now +1 hour'));
Here we are using DateTime
and DateInterval
for getting desired output.
<?php
ini_set('display_errors', 1);
$dateTimeObj= new DateTime();
$dateTimeObj->add(new DateInterval("PT1H"));
echo $dateTimeObj->format('Y-m-d H:i:s');