E
E
Evgeny Nizamiev2014-10-08 14:18:36
JavaScript
Evgeny Nizamiev, 2014-10-08 14:18:36

How to add time easily in javascript?

Input data - 8:30
To this number you need to add, say, 45 minutes.
The output should output the line - 9:15
How to make it easier / more correct / more elegant?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Pushkarev, 2014-10-09
@RadiationX

var time1 = new Date('9.10.2014 8:45')
  , time2 = new Date(+time1 + 45 * 6e4); // => Thu Oct 09 2014 09:15:00

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question