admin管理员组

文章数量:1287800

Is there a JavaScript library that would provide functionality of a "time difference" object?

For example, let's say I have:

time1 = Date(...)
time2 = Date(...)

timeDelta = time2 - time2

By default that just gives me milliseconds, which I can work with, but it would be nice to already have something available so I dont have to re-invent the wheel. What I'm shooting for is something like this:

timeDelta.hours // would give the number of hours between time2 and time1
time1 + timeDelta // would equal time2

Any suggestions?

Thanks,

Is there a JavaScript library that would provide functionality of a "time difference" object?

For example, let's say I have:

time1 = Date(...)
time2 = Date(...)

timeDelta = time2 - time2

By default that just gives me milliseconds, which I can work with, but it would be nice to already have something available so I dont have to re-invent the wheel. What I'm shooting for is something like this:

timeDelta.hours // would give the number of hours between time2 and time1
time1 + timeDelta // would equal time2

Any suggestions?

Thanks,

Share Improve this question asked Feb 22, 2012 at 18:59 GoroGoro 10.2k23 gold badges79 silver badges108 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 8

Necro Post!

http://momentjs./

You're wele. :P

Try this: http://www.datejs./

本文标签: javascriptIs there a library that would provide time delta functionalityStack Overflow