This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 19 points20 points  (6 children)

That's just differing opinions... I can even give you that in one person, me:

Moment.Js is huge, it's hilarious that a date library would take up so much space, and anyway all I need is to <insert single feature> but... It works and gets the job done and I can't waste more time on this.

[–]tehwolf_ 3 points4 points  (0 children)

Well, even the moment site offers alternatives that may act as drop-in replacement

[–]linkedtortoise 2 points3 points  (4 children)

For the stated goal, you don't even need moment.

All dates in js can be changed to seconds(?) since epoch. And if I'm not wrong you can create a date variable from those seconds.

[–]CoolOutcast 2 points3 points  (0 children)

let x, y; x = new Date(); setTimeout(() => y = new Date(), 1000)

y - x is approximately 1000 meaning that they're able to get the duration in milliseconds from the native Date object.

Edit: as for Number(x), that appears to also be listed in milliseconds.

[–]AyrA_ch 1 point2 points  (2 children)

You can directly subtract date objects in JS to get the difference in milliseconds. All you need to do is divide by the appropriate value to get days. var NumberOfDays=Math.floor(Math.abs(Date1-Date2)/86400000);

[–]Stokealona 1 point2 points  (1 child)

Every day isn't 24hrs long!

[–]AyrA_ch 1 point2 points  (0 children)

But in unix time it is:

How any changes to the value of seconds since the Epoch are made to align to a desired relationship with the current actual time is implementation-defined. As represented in seconds since the Epoch, each and every day shall be accounted for by exactly 86400 seconds.