I have the following Javascript/Typescript code to convert a string to a Luxon DateTime:
import { DateTime } from 'luxon';
const x = '2023-10-27T01:00:57.830+00:00'
const y = DateTime.fromFormat(x, 'yyyy-MM-dd');
console.log('y = ', y)
This produces the following output:
y = DateTime {
ts: 1698282057830,
_zone: SystemZone {},
loc: Locale {
locale: 'en-US',
numberingSystem: null,
outputCalendar: null,
intl: 'en-US',
weekdaysCache: { format: {}, standalone: {} },
monthsCache: { format: {}, standalone: {} },
meridiemCache: null,
eraCache: {},
specifiedLocale: null,
fastNumbersCached: null
},
invalid: Invalid {
reason: 'unparsable',
explanation: `the input "2023-10-27T01:00:57.830+00:00" can't be parsed as format yyyy-MM-dd`
},
weekData: null,
c: null,
o: null,
isLuxonDateTime: true
}
How to properly convert this object?
Try using
fromISOmethod.