Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
Chrome 122
Mac OS X 10.15.7
Desktop
10 months ago
Test name Executions per second
moment 250810.5 Ops/sec
date-fns 199598.8 Ops/sec
HTML Preparation code:
x
 
1
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
2
<script src="https://cdnjs.cloudflare.com/ajax/libs/date-fns/1.30.1/date_fns.min.js"></script>
3
Script Preparation code:
 
window.__date__ = new Date();
window.__expected__ = '2000/01/06';
Tests:
  • moment

     
    var actual = moment(__date__).format('YYYY/MM/DD');
    console.assert(actual === __expected__);
  • date-fns

     
    var actual = dateFns.format(__date__, 'YYYY/MM/DD');
    console.assert(actual === __expected__);