Issue
I'm not sure if this is possible, but I want to get the PC's Time Zone using Angular. I just need the timezone because I need to format it in ('+H:MM').
I understand Angular only formats it one way ('+HHMM'), so I want to store this Time Zone and put in a string that I can then manipulate later.
Also I don't want to use plugins and/or libraries, if possible.
Solution
I suggest you to use Momentjs:
var from = new Date();
var date = moment(from).format('Z'); //ZZ
alert(date);
Or you can perform a regular expression on the Date:
var from = new Date();
var res = from.toString().match(/[\+,\-](\d{4})\s/g);
alert(res);
But I'm not sure it is very robust.
I hope it helps.
Answered By - thegio
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.