Reputation: 3509
I am using Angular.js with angular-moment and I am trying to display a date in a different timezone:
p(style="font-size: 70%",am-time-ago="thing.date")
I am including moment.js, as well as the moment.js timezone data (this file). In my .html file:
<script src="bower_components/moment/moment.js"></script>
<script src="bower_components/moment-timezone/moment-timezone-with-data.js"></script>
I have also added the configuration in the Angular.js file, as it says on the angular-moment Github page:
angular.module('myApp')
.constant('angularMomentConfig', { timezone: 'America/New_York' })
I have tried quite a couple of permutations up to now, but nothing seems to work. I have no idea what I might be doing wrong, so any suggestion is more than welcome.
Upvotes: 0
Views: 3494
Reputation: 4049
Here is my solution. Wandered to this question trying to find solution. So Here it is if someone else wanders here too looking for same answer.
Since version 1.0.0-beta.1, time zone can be set using amMoment service. Just inject the amMoment service and call changeTimeZone:
amMoment.changeTimezone('Europe/London');
Upvotes: 1
Reputation: 12748
You say to use angular-moments.js but are not including the angular-moments.js itself to your code.
Look instructions from https://www.npmjs.com/package/angular-momentjs , there the suggestion is to use bower and npm with the following commands:
You can download angular-momentjs by:
- (preferred) Using bower and running bower install angular-momentjs --save
- Using npm and running npm install angular-momentjs --save
and the result would be:
<script src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.5.1/moment.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular.min.js"></script>
<script src="app/bower_components/angular-momentjs/angular-momentjs.js"></script>
Upvotes: 1