Using JavaScript, How can I subtract from HH:MM:SS?
For example, I have 12:54:45 and I want to subtract 11:35:53 for remaining time in 4732 seconds
Using JavaScript, How can I subtract from HH:MM:SS?
For example, I have 12:54:45 and I want to subtract 11:35:53 for remaining time in 4732 seconds
This works
Output is
4732
There are libraries that makes possible to manipulate dates in an easy way: moment.js and day.js are two examples of choice.
More...
More...
Also, for seconds manipulation, Unix time can be useful. It allows to describe time as the number of seconds elapsed since 1st January 1970.
I chose
2000-01-01
as the date, as it does not matter as long it is the same. We only want to calculate the difference.