Quantcast
Channel: Getting the client's time zone (and offset) in JavaScript - Stack Overflow
Viewing all articles
Browse latest Browse all 34

Answer by JohnP2 for Getting the client's time zone (and offset) in JavaScript

$
0
0

If all you need is the "MST" or the "EST" time zone abbreviation:

function getTimeZone(){    var now = new Date().toString();    var timeZone = now.replace(/.*[(](.*)[)].*/,'$1');//extracts the content between parenthesis    return timeZone;}console.log(getTimeZone());

Viewing all articles
Browse latest Browse all 34

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>