Luxon Manual Reference

Install guide

Luxon provides different builds for different JS environments. See below for a link to the right one and instructions on how to use it. Luxon supports all modern platforms, but see the support matrix for additional details.

Basic browser setup

Just include Luxon in a script tag. You can access its various classes through the luxon global.

<script src="luxon.js"></script>

You may wish to alias the classes you use:

var DateTime = luxon.DateTime;

Internet Explorer

If you're supporting IE 10 or 11, you need some polyfills to get Luxon to work. You have two options: use a polyfilled build or apply the polyfills yourself. The polyfilled builds are here:

Note that none of this polyfills the Intl API to enhance internationalization or zone capabilities; this is just about making sure the browser has stuff like Object.assign. To polyfill that stuff see here.

To polyfill it yourself, use polyfill.io:

<script src="https://cdn.polyfill.io/v2/polyfill.min.js"></script>

This will also add the Intl stuff, so that's two birds with one stone.

Node

Supports Node 6+. Install via NPM:

npm install --save luxon
const { DateTime } = require('luxon');

If you want to work with locales, you'll need to have full-icu support installed in Node. You can build Node with it, use an NPM module to provide it, or find it prepackaged for your platform, like brew install node --with-full-icu. If you skip this step, Luxon still works but methods like setLocale() will do nothing.

AMD (System.js, RequireJS, etc)

requirejs(['luxon'], function(luxon) {
  //...
});

There are also polyfilled versions of this; see the Internet Explorer section above for additional options and caveats.

ES6

import { DateTime } from 'luxon';

Webpack

npm install --save luxon
import { DateTime } from 'luxon';

Meteor

[Help wanted.]