Moment startOf Day vs string parsing (v6)

Revision 6 of this benchmark created by Dylan Robinson on


Preparation HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.11.1/moment.js"></script>

Setup

var dateObj = new Date();
    var momentObj = moment();

Test runner

Ready to run.

Testing in
TestOps/sec
js Date
var s = dateObj.toString().slice(0,15);
return new Date(s).getTime()
ready
momnet date
var a = momentObj.clone().startOf('day')
return a.unix();
ready
JS Date setHours
var s = new Date(dateObj);
s.setHours(0,0,0,0);
s.getTime();
ready

Revisions

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

  • Revision 1: published by Zachary Belford on
  • Revision 2: published by Zachary Belford on
  • Revision 3: published on
  • Revision 6: published by Dylan Robinson on