0

Is there any function or logic in javascript by which I can get my time in microseconds? I'm trying to get time asvar s = new Date(); here the minimum unit I get is Milliseconds, but how can I get this time in microseconds?

L84
  • 45,514
  • 58
  • 177
  • 257
Shilpa Soni
  • 2,034
  • 4
  • 27
  • 38

2 Answers2

1

You can also use the new "High Resolution Time" http://www.w3.org/TR/hr-time/

Example and demo here: http://www.sitepoint.com/10-html5-apis-worth-looking/

HasanAboShally
  • 18,459
  • 7
  • 30
  • 34
1

use package microtime To install : npm install microtime

var us = require('microtime');
var us_time = us.now();

To know more about microtime check this link

Rose
  • 71
  • 6
  • If you intend to use this to get the system date and time in milliseconds rather than using this for timing, this is the better answer. – waternova Aug 09 '17 at 20:35