Skip to Content

localTimestamp()

Create a timestamp in the user’s local timezone.

JavaScript February 22, 2017

Usage

JavaScript
localTimestamp()

Parameters

This function does not accept any parameters. Is this incorrect?

Additional Notes

If Google Analytics is blocked by the user, this function will only return false.

Source File

Located in /inc/analytics.php on line 394.

JavaScript
        function localTimestamp(){
            var now = new Date();
            var tzo = -now.getTimezoneOffset();
            var dif = ( tzo >= 0 )? '+' : '-';
            var pad = function(num){
                var norm = Math.abs(Math.floor(num));
                return (( norm < 10 )? '0' : '') + norm;
            };
            return Math.round(now/1000) + ' (' + now.getFullYear() + '-' + pad(now.getMonth()+1) + '-' + pad(now.getDate()) + ' ' + pad(now.getHours()) + ':' + pad(now.getMinutes()) + ':' + pad(now.getSeconds()) + '.' + pad(now.getMilliseconds()) + ' UTC' + dif + pad(tzo/60) + ':' + pad(tzo%60) + ')';
        }

Override

To override or disable this JavaScript function, simply redeclare it with the exact same function name.

JavaScript
function localTimestamp(){
    //Write your own code here, leave it blank, or return false.
}