I need to generate date and time today + 1
and time 7:00 AM
in PHP
I tried below code it is not working
$dateTime = date('d/m/y');
echo date( "Y-m-d h:i", strtotime( $dateTime . ' 7:00 1 Day' ) );
``
1
You can simply use the DateTime class.
For example:
<?php
$date = new DateTime(); // This will give you today date
$date->modify('+1 day');
$date->modify('07:00');
$formattedDate = $date->format('Y-m-d H:i');
?>
This snippet should output the following string [“2024-05-23 07:00”], considering today date is 2024-05-22.