function A() {return new Date().getTime();}
function B() {return new Date().valueOf();}
function C() {return +new Date();}
function D() {return new Date()*1;}
function E() {return Date.now();}
function F() {return Number(new Date());}
function G() {// this solution returns time counted from loading the page.// (and on Chrome it gives better precission)return performance.now();}
// TEST
log = (n,f) => console.log(`${n} : ${f()}`);
log('A',A);log('B',B);log('C',C);log('D',D);log('E',E);log('F',F);log('G',G);
This snippet only presents code used in external benchmark
/*** Equivalent to PHP's time(), which returns* current Unix timestamp.** @param {string} unit - Unit of time to return.* - Use 's' for seconds and 'ms' for milliseconds.* @return {number}*/time(unit = 's') {return unit == 's' ? Math.floor(Date.now() / 1000) : Date.now()}