Public
Edited
Oct 27, 2023
Insert cell
Insert cell
{
let dts = [
"2011-12-30T09:00:00Z",
"2011-12-30T09:59:00Z",
"2011-12-30T10:00:00Z",
"2011-12-30T10:59:00Z",
"2011-12-30T11:00:00Z"
];

const pd = dts.map(d => dateFns.parseISO(d))
return `first two ${dateFns.differenceInDays(pd[0], pd[1])}. First and last: ${dateFns.differenceInDays(pd[0], pd[pd.length -1])}. `
}
Insert cell
{
let sd = "2011-12-29";
let ed = "2011-12-31";
return {
dfns: dateFns.differenceInDays(new Date(sd), new Date(ed)),
mt: moment.tz(sd, "Pacific/Apia").diff(moment.tz(ed, "Pacific/Apia"), 'days'),
ld: luxon.local(),
m: {
s: moment.tz(sd, "Pacific/Apia").format(),
e: moment.tz(ed, "Pacific/Apia").format(),
a: moment.tz(sd, "Pacific/Apia").add(1, "day").format()
},
mts: moment.utc("2011-12-30T09:00:00Z").tz("Pacific/Apia").format(),
mte: moment.utc("2011-12-30T11:00:00Z").tz("Pacific/Apia").format()
};
}
Insert cell
moment.tz.guess()
Insert cell
dateFns = import("https://cdn.skypack.dev/date-fns")
Insert cell
moment = (await import("https://cdn.skypack.dev/moment")).default
Insert cell
momentTZ = import("https://cdn.skypack.dev/moment-timezone")
Insert cell
luxon = (await import("https://cdn.skypack.dev/luxon")).DateTime
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more