Public
Edited
Feb 1, 2023
Importers
9 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
new Date("2022-09-11") + "" === new Date("2022/09/11") + ""
Insert cell
new Date("2022-09-11") + "" === new Date(2022, 9, 11) + "" // expected output: false (months are 0-indexed)
Insert cell
new Date("+0000-00-00T00:00Z")
Insert cell
Insert cell
date("2022-09-11") + "" === date("2022/09/11") + ""
Insert cell
date("2022-09-11") + "" === date(2022, 9, 11) + "" // expected output: true (months are 1-indexed)
Insert cell
date("+0000-00-00T00:00Z")
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
+date()
Insert cell
+date(date())
Insert cell
date(1996, 19, 96, 19, 96, 1996).toISOString()
Insert cell
Insert cell
+date(undefined)
Insert cell
+date(void 0)
Insert cell
Insert cell
date(null)
Insert cell
date(0)
Insert cell
Insert cell
date(/* string */ new Date().getFullYear() + "")
Insert cell
date(/* number */ new Date().getFullYear()) // timestamp value!
Insert cell
Insert cell
date(new Date().getFullYear(), null)
Insert cell
date(new Date().getFullYear(), 0)
Insert cell
Insert cell
date("2022-9-0")
Insert cell
date("2022/9/0")
Insert cell
date("2022 9 0")
Insert cell
date("2022, 9, 0")
Insert cell
date(0, 0, 0).toISOString()
Insert cell
Insert cell
date(0, 0, 0).toISOString() === date(0, 0).toISOString()
Insert cell
Insert cell
date("2022-9--1")
Insert cell
date(2022, 9, -30)
Insert cell
date(2022, 8, 0)
Insert cell
date("2022/8")
Insert cell
date(2022, 8)
Insert cell
date(2022, 9, -30) + "" === date(2022, 8, 0) + "" // expected output: true
Insert cell
date(2022, 8) + "" === date(2022, 8, 0) + "" // expected output: false
Insert cell
Insert cell
date("2022-09-10#24:00") + "" === date("2022-09-11#00:00") + "" // expected output: true
Insert cell
Insert cell
date("2022-032").toISOString() === date("2022-02-01").toISOString() // expected output: true
Insert cell
date("2022-2022").toISOString() === date(2022, 0, 2022).toISOString() // expected output: true
Insert cell
Insert cell
range = [+date("1970/-99999999"), +date("1970/100000001")]
Insert cell
date("1900/-693960")
Insert cell
Insert cell
date("2022-032T20:22").toISOString() === date("2022-02-01T20:22").toISOString() // expected output: true
Insert cell
Insert cell
((dt) => [dt.toISOString(), [dt?.offset, +dt?.offset]])(date("0-1-1#-24:00")) // WARNING: this is *NOT* a time zone offset!
Insert cell
((dt) => [dt.toISOString(), [dt?.offset, +dt?.offset]])(date("0-1-1#0+24:00"))
Insert cell
date("0-1-1#+24:00").toISOString() === date("0-1-1#0+24:00").toISOString() // expected output: false
Insert cell
date("0-1-1#0+24:00").toISOString() ===
new Date("-000001-12-31T23:59+23:59").toISOString() // expected output: true
Insert cell
((dt) => [dt.toISOString(), [dt?.offset, +dt?.offset]])(date("0-1-1#+24:00")) // WARNING: this is *NOT* a time zone offset!
Insert cell
((dt) => [dt.toISOString(), [dt?.offset, +dt?.offset]])(date("0-1-1#0-24:00"))
Insert cell
date("0-1-1#-24:00").toISOString() === date("0-1-1#0-24:00").toISOString() // expected output: false
Insert cell
date("0-1-1#0-24:00").toISOString() ===
new Date("+000000-01-01T00:01-23:59").toISOString() // expected output: true
Insert cell
Insert cell
((dt) => [dt.toISOString(), [dt?.offset, +dt?.offset]])(date("TZ")) // Coordinated Universal Time
Insert cell
((dt) => [dt.toISOString(), [dt?.offset, +dt?.offset]])(date("TJ")) // local time
Insert cell
((dt) => [dt.toISOString(), [dt?.offset, +dt?.offset]])(
date("1970-1-1#20:22:2.22")
) // Coordinated Universal Time
Insert cell
((dt) => [dt.toISOString(), [dt?.offset, +dt?.offset]])(
date("1970-1-1#20:22:2.22J")
) // local time
Insert cell
((dt) => [dt.toISOString(), [dt?.offset, +dt?.offset]])(
date(2022, 9, 11, 20, 22, 0, 2022)
)
Insert cell
((dt) => [dt.toISOString(), [dt?.offset, +dt?.offset]])(
date("2022-09-11T22:22:02.022+02:00")
)
Insert cell
Insert cell
date([
/* YYYY-MM-DD */ "2022-22-20",
/* HH:mm:ss.sss w/o Z suffix or time zone offset */ "22:20:02.022"
])
Insert cell
((dt) => [dt.toISOString(), [dt?.offset, +dt?.offset]])(
date([
/* YYYY-MM-DD */ "2022-22-20",
/* HH:mm:ss.sss w/ positive time zone offset */ "22:20:02.022+20:22"
])
)
Insert cell
((dt) => [dt.toISOString(), [dt?.offset, +dt?.offset]])(
date([
/* YYYY-MM-DD */ "2022-22-20",
/* HH:mm:ss.sss w/ negative time zone offset */ "22:20:02.022-20:22"
])
)
Insert cell
date(["2022", "20:22:02.22"])
Insert cell
date(["2022-032", "20:22:02.022Z"])
Insert cell
date([
/* array can be empty */
])
Insert cell
date([0])
Insert cell
date([0, 0])
Insert cell
date(["0, 0"]) // note the subtle difference
Insert cell
date(["0/0/0", 0])
Insert cell
date(["0000-01-01", "00:00+20:22"]).toISOString() ===
new Date("+000000-01-01T00:00+20:22").toISOString() // expected output: true
Insert cell
date(["0000-01-01", "00:00-20:22"]).toISOString() ===
new Date("+000000-01-01T00:00-20:22").toISOString() // expected output: true
Insert cell
Insert cell
+date(1970, 0, -100000000, 24)
Insert cell
date(1970, 0, -100000000, 24).toISOString()
Insert cell
date(1970, 1, -100000000 - 30).toISOString()
Insert cell
date(1970, 1, 100000000 + 1).toISOString()
Insert cell
date(1970, 0, +100000000, 24).toISOString()
Insert cell
+date(1970, 0, +100000000, 24)
Insert cell
date(1970, 0, -100000000 + 1) + "" === date(1970, 1, -100000000 - 30) + "" // expected output: true
Insert cell
-1 * +date("1970/-99999999") === +date("1970/100000001") // expected output: true
Insert cell
datediff("1970/-99999999", 0)
Insert cell
datediff("1970/100000001", 0)
Insert cell
Insert cell
date(0).toISOString() === date(0, 0).toISOString() // expected output: false
Insert cell
date([0]).toISOString() === date([1970, 0]).toISOString() // expected output: true
Insert cell
date(0).toISOString() === date("1970").toISOString() // expected output: true
Insert cell
+date(0)
Insert cell
+date(0, 0)
Insert cell
+date("1970")
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
datediff(0)
Insert cell
datediff(null, 0)
Insert cell
datediff(void 0, 0)
Insert cell
datediff(0, 0)
Insert cell
datediff(new Date(Date.UTC(0, 0, -693960)), new Date(Date.UTC(0, 0, 0)))
Insert cell
datediff("+1970-01-01T0+24:59" /* this is a time zone offset */, 0)
Insert cell
datediff("+1970-01-01T-24:59" /* this is *NOT* a time zone offset! */, 0)
Insert cell
datediff("+1970-01-01T+24:59" /* this is *NOT* a time zone offset! */, 0)
Insert cell
datediff("+1970-01-01T0-24:59" /* this is a time zone offset */, 0)
Insert cell
datediff("+1970-01-01T-48", 0)
Insert cell
datediff("+1970-01-01T+48", 0)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
((dt) => [dt.toISOString(), [dt?.offset, +dt?.offset]])(date("1970-1-1TY"))

Insert cell
((dt) => [dt.toISOString(), [dt?.offset, +dt?.offset]])(
date("1970-1-1#0" + letter2offset("Yankee"))
)
Insert cell
((dt) => [dt.toISOString(), [dt?.offset, +dt?.offset]])(
date("1970-1-1#0" + letter2offset("Juliett"))
)
Insert cell
((dt) => [dt.toISOString(), [dt?.offset, +dt?.offset]])(
date("1970-1-1#0" + letter2offset("Mike"))
)
Insert cell
((dt) => [dt.toISOString(), [dt?.offset, +dt?.offset]])(date("1970-1-1TM"))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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