Moment vs js date construction (v2)

Revision 2 of this benchmark created by Andrew Dittes on


Description

Test different methods of getting a JS Date object from a moment object.

Preparation HTML

<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.3/moment.min.js"></script>

Setup

var m = moment();
    var d = new Date();
    var now  = Date.now();
    var d1;

Test runner

Ready to run.

Testing in
TestOps/sec
moment date
d1 = m.toDate();
ready
js date from moment
d1 = new Date(m.valueOf())
ready
moment date (_d)
d1 = m._d
ready
js date from timestamp
d1 = new Date(now)
ready
js date from unixms
d1 = new Date(m.unix() *1000)
ready
js date from isostring
d1 = new Date(m.toISOString())
ready

Revisions

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

  • Revision 2: published by Andrew Dittes on