date iso extract

Benchmark created on


Setup

const date = new Date();

Test runner

Ready to run.

Testing in
TestOps/sec
getting date parts separately and concat (naively)
`${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`
ready
getting date parts separately and concat (accurate ISO)
`${date.getFullYear()}-${`${date.getMonth() + 1}`.padStart(2, "0")}-${`${date.getDate()}`.padStart(2, "0")}`
ready
toISOString and slice
date.toISOString().slice(0, 10)
ready
toISOString and substring
date.toISOString().substring(0, 10)
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.