UNPKG

phpjs

Version:

php.js offers community built php functions in javascript

13 lines (11 loc) 419 B
function microtime(get_as_float) { // discuss at: http://phpjs.org/functions/microtime/ // original by: Paulo Freitas // example 1: timeStamp = microtime(true); // example 1: timeStamp > 1000000000 && timeStamp < 2000000000 // returns 1: true var now = new Date() .getTime() / 1000; var s = parseInt(now, 10); return (get_as_float) ? now : (Math.round((now - s) * 1000) / 1000) + ' ' + s; }