Created
November 18, 2015 11:05
-
-
Save rogiervandenberg/dd6f09a26a493243042a to your computer and use it in GitHub Desktop.
Returns a timestamp corrected for the current timezone, instead of getting the UTC timezone. This can be useful for tracking timed-events in the perception of a user/visitor of your application/website in e.g. Google Tag Manager.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getLocalTimeStamp () { | |
var currentDate = new Date(); | |
var currentTime = currentDate.getTime(); | |
var localOffset = (-1) * currentDate.getTimezoneOffset() * 60000; | |
var stamp = Math.round(new Date(currentTime + localOffset).getTime() / 1000); | |
return stamp; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment