UNPKG

phpjs

Version:

php.js offers community built php functions in javascript

12 lines (10 loc) 412 B
function microtime(get_as_float) { // From: http://phpjs.org/functions // + 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; }