Skip to content
Advertisement

Adding 1 hour to time variable

I have a time to which I want to add an hour:

JavaScript

I’ve tried:

JavaScript

But none of the above work.

Advertisement

Answer

Worked for me..

JavaScript

Explanation:

strtotime('10:09') creates a numerical timestamp in seconds, something like 1510450372. Simply add or remove the amount of seconds you need and use date() to convert it back into a human readable format.

JavaScript

time() also creates a numerical timestamp but for right now. You can use it in the same way.

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement