I have a date and i would like to only modify the time stamp in it and keep the day month year the same. Any way to do this?
The date i have this 2017-07-12 13:41:23
I have tried creating the date as
date("Y-m-d H:i:s" , strtotime(strtr("12-07-2017 13:41:23", "/", "-")))
Thanks
This code worked for me
(date("Y-m-d" , strtotime("12-07-2017 13:41:23")). " ".date("H:i:s"));
I don't know if this is exactly what you need
$xx = '12-07-2017 13:41:23';
$result = date('Y-m-d', strtotime($xx)) . date('H:i:s', time());
When modifying dates and times, save yourself a world of pain and use DateTime objects. To set the time on a timestamp to the current time, simply use DateTime::setTime:
$date = new DateTime("12-07-2017 13:41:23");
$date->setTime(date('G'),date('i'),date('s'));
echo $date->format("Y-m-d H:i:s"); // Outputs 2017-07-12 01:36:29