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

Posted by Henry on Stack Overflow See other posts from Stack Overflow or by Henry
Published on 2010-04-03T17:23:29Z Indexed on 2010/04/03 17:33 UTC
Read the original article Hit count: 162

Filed under:
|
|

Hi guys, 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.

<?php

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

$new_time= strtotime($my_time);
$new_time+=$seconds2add;

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

© Stack Overflow or respective owner

Related posts about php

Related posts about time