Function: microtime version 122

Function:
Description: Returns either a string or a float containing the current time in seconds and microseconds.
Version:
Status: latest
Date: 2011-12-20 05:33
Summary: Import from phpjs.
Programmer: jj5
Code
1
2
3
4
5
6
7
8
9
10
function microtime (get_as_float) {
    // http://jsphp.co/jsphp/fn/view/microtime
    // +   original by: Paulo Freitas
    // *     example 1: timeStamp = microtime(true);
    // *     results 1: timeStamp > 1000000000 && timeStamp < 2000000000
    var now = new Date().getTime() / 1000;
    var s = parseInt(now, 10);

    return (get_as_float) ? now : (Math.round((now - s) * 1000) / 1000) + ' ' + s;
}
[top]

Comments

There are no comments yet, be the first!

Please Login or Register to post comments.