php - I have time like this 12:00:00 AM how to add + two hours with the time -
this question has answer here:
- add 'x' amount of hours date 8 answers
i have time 10:00:00 how add + 2 hours time.
i have tried this:
$today = "10:00:00 am"; $starttime = "02:00:00"; $endtime = date("g:i:s a", $starttime+$today); echo $endtime;
i vanilla php, object style using datatime()
$date = new datetime('10:00:00 am'); $date->modify('+2 hours'); echo $date->format("g:i:s a");
output:
12:00:00 pm
or can try lib ouzo goodies, , in fluent way:
echo clock::at('10:00:00 am')->plushours(2)->format("g:i:s a");
output:
12:00:00 pm
Comments
Post a Comment