Skip to content

Instantly share code, notes, and snippets.

@joemaller
Created January 23, 2018 14:29
Show Gist options
  • Save joemaller/5e259d5c366a3d3bc15e40ed97b63f7d to your computer and use it in GitHub Desktop.
Save joemaller/5e259d5c366a3d3bc15e40ed97b63f7d to your computer and use it in GitHub Desktop.
Luxon Timestamps

Finding this took me longer than it should have, probably because I was impatiently looking for "timeststamp" instead of "milliseconds of the Unix epoch". For future searchers, Luxon uses the methods DateTime.fromMillis and DateTime.valueOf.

// Create a Luxon DateTime from a JS Unix timestamp
const ts = new Date().getTime();     // 1516717417146
const dt = DateTime.fromMillis(ts);  // { ts: 2018-01-23T09:23:37.146-05:00 ...
console.log(dt.valueOf());           // 1516717417146
@haywirez
Copy link

haywirez commented Sep 6, 2018

Thanks! Came across this randomly and it helped!

@ellis2323
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment