Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Intl.DateTimeFormat perf.
(version: 0)
Intl.DateTimeFormat perf.
Comparing performance of:
old vs new
Created:
3 years ago
by:
Guest
Jump to the latest result
Tests:
old
for(i=0; i<10000; i++){ formatShortDate(new Date("2020-08-19T23:13:44.514Z"), undefined, false); } function formatShortDate(ts, dflt,timezone) { if (!ts && dflt) return dflt; var tsOptions = { month: "numeric", day: "numeric", hour: "numeric", minute: "numeric", hour12: false }; var d = (ts) ? (new Date(ts)) : (new Date()); if (!timezone ) { tsOptions.timeZone = "UTC"; } var d = new Date(ts); return new Intl.DateTimeFormat("lookup", tsOptions).format(d); }
new
for(i=0; i<10000; i++){ formatShortDate(new Date("2020-08-19T23:13:44.514Z"), undefined, false); } function formatShortDate(ts, dflt, timezone) { if (!ts && dflt) return dflt; const date = new Date(ts); var month, day, hours, minutes, utcDate; if (!timezone) { utcDate = new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds())); month = (utcDate.getUTCMonth() + 1).toString().padStart(2, '0'); day = utcDate.getUTCDate().toString().padStart(2, '0'); hours = utcDate.getUTCHours().toString().padStart(2, '0'); minutes = utcDate.getUTCMinutes().toString().padStart(2, '0'); } else { month = (date.getMonth() + 1).toString().padStart(2, '0'); day = date.getDate().toString().padStart(2, '0'); hours = date.getHours().toString().padStart(2, '0'); minutes = date.getMinutes().toString().padStart(2, '0'); } return `${day}/${month} ${hours}:${minutes}`; }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
old
new
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
Caching the DateTimeFormatter
new Intl.DateTimeFormat vs cached Intl.DateTimeFormat
Intl.DateTimeFormat() vs Date().ISOString()
new Intl.DateTimeFormat vs cached Intl.DateTimeFormat vs date method
new Intl.DateTimeFormat vs cached Intl.DateTimeFormat vs custom
Comments
Confirm delete:
Do you really want to delete benchmark?