### DateTime.now Source: https://moment.github.io/luxon/demo/global.html Get the current date and time. ```javascript DateTime.now() ``` -------------------------------- ### DateTime.now().setZone().startOf Source: https://moment.github.io/luxon/demo/global.html Change time zone and set to the start of the day. ```javascript DateTime.now().setZone('America/New_York').startOf('day') ``` -------------------------------- ### Get end of day one week ago in a specific time zone Source: https://moment.github.io/luxon Returns the ISO string for the end of the day one week ago in the America/New_York time zone. Demonstrates chaining of setZone, minus, endOf, and toISO. ```javascript DateTime.now().setZone('America/New_York').minus({weeks:1}).endOf('day').toISO(); ``` -------------------------------- ### DateTime.now().toRelativeCalendar Source: https://moment.github.io/luxon/demo/global.html Get a relative calendar string for the date. ```javascript DateTime.now().plus({ days: 1 }).toRelativeCalendar() ``` ```javascript DateTime.now().plus({ days: -1 }).toRelativeCalendar() ``` ```javascript DateTime.now().plus({ months: 1 }).toRelativeCalendar() ``` ```javascript DateTime.now().setLocale('fr').plus({ days: 1 }).toRelativeCalendar() ``` ```javascript DateTime.now().setLocale('fr').plus({ days: -1 }).toRelativeCalendar() ``` ```javascript DateTime.now().setLocale('fr').plus({ months: 1 }).toRelativeCalendar() ``` -------------------------------- ### DateTime.utc().toISO Source: https://moment.github.io/luxon/demo/global.html Get current UTC time in ISO format. ```javascript DateTime.utc().toISO() ``` -------------------------------- ### Info.features Source: https://moment.github.io/luxon/demo/global.html Check available Luxon features. ```javascript Info.features() ``` -------------------------------- ### DateTime.fromISO Source: https://moment.github.io/luxon/demo/global.html Create a DateTime from an ISO string. ```javascript DateTime.fromISO('2017-05-15') ``` ```javascript DateTime.fromISO('2017-05-15T17:36') ``` ```javascript DateTime.fromISO('2017-W33-4') ``` ```javascript DateTime.fromISO('2017-W33-4T04:45:32.343') ``` -------------------------------- ### DateTime.local creation Source: https://moment.github.io/luxon/demo/global.html Create a local DateTime object. ```javascript DateTime.local(2017, 5, 15, 17, 36) ``` -------------------------------- ### DateTime.fromFormat Source: https://moment.github.io/luxon/demo/global.html Create a DateTime from a custom format string. ```javascript DateTime.fromFormat('12-16-2017', 'MM-dd-yyyy') ``` ```javascript DateTime.fromFormat('May 25, 1982', 'MMMM dd, yyyy') ``` ```javascript DateTime.fromFormat('mai 25, 1982', 'MMMM dd, yyyy', { locale: 'fr' }) ``` -------------------------------- ### DateTime.now().toFormat Source: https://moment.github.io/luxon/demo/global.html Format the current date using a custom format string. ```javascript DateTime.now().toFormat('MM-dd-yyyy') ``` ```javascript DateTime.now().toFormat('MMMM dd, yyyy') ``` ```javascript DateTime.now().setLocale('fr').toFormat('MMMM dd, yyyy') ``` -------------------------------- ### DateTime.fromObject Source: https://moment.github.io/luxon/demo/global.html Create a DateTime from an object. ```javascript DateTime.fromObject({ year: 2017, month: 5, day: 15, hour: 17, minute: 36 }) ``` -------------------------------- ### DateTime.fromObject with zone Source: https://moment.github.io/luxon/demo/global.html Create a DateTime from an object with a specific time zone. ```javascript DateTime.fromObject({ year: 2017, month: 5, day: 15, hour: 17, minute: 36 }, { zone: 'America/New_York' }) ``` ```javascript DateTime.fromObject({ year: 2017, month: 5, day: 15, hour: 17, minute: 36 }, { zone: 'Asia/Singapore' }) ``` -------------------------------- ### DateTime.now().toLocaleString Source: https://moment.github.io/luxon/demo/global.html Format the current date as a localized string. ```javascript DateTime.now().toLocaleString() ``` ```javascript DateTime.now().setLocale('zh').toLocaleString() ``` ```javascript DateTime.now().toLocaleString(DateTime.DATE_MED) ``` ```javascript DateTime.now().setLocale('zh').toLocaleString(DateTime.DATE_MED) ``` ```javascript DateTime.now().setLocale('fr').toLocaleString(DateTime.DATE_FULL) ``` -------------------------------- ### DateTime.now().toUnixInteger Source: https://moment.github.io/luxon/demo/global.html Convert current time to a Unix integer. ```javascript DateTime.now().toUnixInteger() ``` -------------------------------- ### DateTime.utc creation Source: https://moment.github.io/luxon/demo/global.html Create a UTC DateTime object. ```javascript DateTime.utc(2017, 5, 15, 17, 36) ``` -------------------------------- ### DateTime.local().toUTC Source: https://moment.github.io/luxon/demo/global.html Convert a local DateTime to UTC. ```javascript DateTime.local(2017, 5, 15, 17, 36).toUTC() ``` -------------------------------- ### DateTime.now().plus Source: https://moment.github.io/luxon/demo/global.html Add time to the current date. ```javascript DateTime.now().plus({minutes: 15, seconds: 8}) ``` ```javascript DateTime.now().plus({days: 6}) ``` -------------------------------- ### DateTime.now().toObject Source: https://moment.github.io/luxon/demo/global.html Convert current time to an object representation. ```javascript DateTime.now().toObject() ``` -------------------------------- ### DateTime.now().diff Source: https://moment.github.io/luxon/demo/global.html Calculate the difference between two dates. ```javascript DateTime.now().diff(DateTime.local(1982, 5, 25)).milliseconds ``` ```javascript DateTime.now().diff(DateTime.local(1982, 5, 25), 'days').days ``` ```javascript DateTime.now().diff(DateTime.local(1982, 5, 25), ['days', 'hours']) ``` -------------------------------- ### DateTime.now().setZone Source: https://moment.github.io/luxon/demo/global.html Change the time zone of the current time. ```javascript DateTime.now().setZone('America/New_York') ``` -------------------------------- ### DateTime.utc().toLocal Source: https://moment.github.io/luxon/demo/global.html Convert a UTC DateTime to local time. ```javascript DateTime.utc(2017, 5, 15, 17, 36).toLocal() ``` -------------------------------- ### DateTime.now().toJSDate Source: https://moment.github.io/luxon/demo/global.html Convert current time to a native JS Date object. ```javascript DateTime.now().toJSDate() ``` -------------------------------- ### DateTime.now().minus Source: https://moment.github.io/luxon/demo/global.html Subtract time from the current date. ```javascript DateTime.now().minus({days: 6}) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.