Skip to content
Advertisement

form type=“time” calculation results in full number only

I’m trying to calculate times from a time input but the result will always be a full number for example 16:45 – 8:30 doesnt result into 8:15 or 8.15 but only 8 and i can’t find a solution to this. Here is the code:

JavaScript

Thanks for the help

Advertisement

Answer

You’re subtracting time string values instead use the following code to get the time difference.

JavaScript

see here as well Subtract time in PHP

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