php - I have time like this 12:00:00 AM how to add + two hours with the time -


this question has answer here:

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

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -