Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateTime.toSeconds returns seconds.milliseconds #565

ThorstenBux opened this issue Aug 31, 2019 · 2 comments


Copy link

commented Aug 31, 2019


I'm wondering why DateTime.toSeconds() does return a floating-point number xxxxx.yyy where yyy represents the milliseconds. If I wanted to have milliseconds I would have called .toMilliSeconds()

DateTime.fromISO("2019-08-31T00:27:39.689Z").toSeconds() // --> 1567211259

DateTime.fromISO("2019-08-31T00:27:39.689Z").toSeconds() // --> 1567211259.689

@icambron icambron closed this Aug 31, 2019


This comment has been minimized.

Copy link

commented Aug 31, 2019

The reason people typically want toSeconds is that they want to pass the result a UNIX system that expects datetimes expressed as epoch seconds, and I believe those systems generally allow for decimals in the input. Thus, leaving in the milliseconds makes the conversion to that representation lossless.

You can alway call Math.floor() or Math.round() on it.


This comment has been minimized.

Copy link

commented Sep 3, 2019

@icambron, thanks for clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.