How to set angular global timezone time globally?
I used angular moment js in angular app. I want to show the date and time according to the current user's timezone. I cannot apply the time zone globally.
https://github.com/urish/angular-moment
I've tried this.
angular.module('myapp').constant('angularMomentConfig', {
timezone: 'Europe/London' // e.g. 'Europe/London'
});
In one of my views -
{{home.eventStart| amDateFormat:'dddd, MMMM Do YYYY, h:mm:ss a'}}
In one of my controllers -
$scope.profile.eventStart = moment(data.start).format('YYYY-MM-DD hh:mm a');
I don't get any changes in either case, even after I set the timezone. Did I miss something?
+3
source to share
5 answers
I had the same problem too.
Here's how to solve it.
You need to include moment-timezone.js v0.3.0 or higher in your project, otherwise the custom timezone functions will not be available.
0
source to share