date iso extract (v2)

Revision 2 of this benchmark created on


Setup

const date = new Date();

Test runner

Ready to run.

Testing in
TestOps/sec
getting date parts separately (fake ISO-like) and concat while using padStart
`${date.getFullYear()}-${`${date.getMonth() + 1}`.padStart(2, "0")}-${`${date.getDate()}`.padStart(2, "0")}`
ready
getting date parts separately (actual UTC) and concat while using padStart
`${date.getUTCFullYear()}-${`${date.getUTCMonth() + 1}`.padStart(2, "0")}-${`${date.getUTCDate()}`.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.