How to use PHP Time function to set a time variable of '09:30', add a specific amount of seconds and then echo the new time

Hopefully you can help me here. I have some code (please see below) which takes the current time, then adds specific seconds to the time and re-displays the time 1 minute in the future.

Instead of the time being the current time, I want it to be a time which I set - say 9:30. Then I want to be able to add, for example 65 seconds and it shows me 9:31.

Please can you show me how to change it from current time, to a specific time I can set myself.

Thank you.


$my_time = date('h:i:s',time());
$seconds2add = 65;

$new_time= strtotime($my_time);

echo date('h:i:s',$new_time);


Change your first line,

 $my_time = date('h:i:s',time());


$my_time = '9:30';


As of PHP 5.2 you can use the DateTime class ( ).

$date = new DateTime(date('h:i:s'));
$date->modify('+65 seconds');
echo $date->format('h:i:s');

Also see:

Need Your Help

Windows 10 sublimelinter-php

sublimetext3 sublimelinter

I just upgraded to windows 10 and I cannot get my sublimelinter-php. I have sublimelinter-css and sublimelinter-jshist working fine.

process running after kill/uninstall

android cpu-usage

I'm working on an app with many libraries included. Later I noticed a couple of occasions where the app process was still draining CPU after closing the app.