Carova

Luxon Date Time Examples

Luxon DateTime common examples. Date objects for now, adding to a date, getting local DateTime string, DateTime time difference

Date and Time right now

1DateTime.now() // 2022-04-25T16:04:03.664-04:00

Date and Time right now as Object

1DateTime.now().toObject() 2// {"year":2022,"month":4,"day":25,"hour":16,"minute":4,"second":3,"millisecond":676}

Date and Time right now in UTC format

1DateTime.now().toUTC() // 2022-04-25T20:04:03.676Z

Date and Time From Object

1DateTime.fromObject({year: 2017, month: 5, day: 15, hour: 17, minute: 36}) // 2017-05-15T17:36:00.000-04:00

Date and Time Now Add Days

1DateTime.now().plus({days: 6}) // 2022-05-01T16:04:03.680-04:00

Date and Time Now Difference in Milliseconds

1DateTime.now().diff(DateTime.local(1982, 5, 25)).milliseconds // 1259769843680

Date and Time Now to Locale String

1DateTime.now().toLocaleString() // "4/25/2022"