Moment Timezone
Playing with Moment TImezone + ie8.
HTML
<script src="http://momentjs.com/downloads/moment.min.js"></script>
<script src="http://momentjs.com/downloads/moment-timezone.min.js"></script>
<script src="http://bestkirdape.freeiz.com/timezone/moment-timezone-data.js"></script>
<!-- stitch this with the module declare in Javascript -->
<body ng-app="myApp">
<div ng-controller="SelectCtrl">The time in
<select ng-model="selectedItem" ng-options="item.label for item in myData | orderBy:'label'" ng-change="updateTime()"></select>is {{formattedTime}}.</div>
</body>
JavaScript
// declare a module
var myApp = this.angular.module('myApp', []);
// declare a controller
myApp.controller('SelectCtrl', function ($scope) {
$scope.myData = [{
label: "Singapore",
value: "Asia/Singapore"
}, {
label: "Sydney",
value: "Australia/Sydney"
}, {
label: "EST5EDT",
value: "EST5EDT"
}, {
label: "Amsterdam",
value: "Europe/Amsterdam"
}, {
label: "Newzealand",
value: "Pacific/Auckland"
},{
label: "London",
value: "Europe/London"
}];
$scope.selectedItem = $scope.myData[0];
$scope.formattedTime = "";
$scope.timer;
$scope.updateTime = function () {
var tempDate;
if(window.moment != undefined){
tempDate = window.moment.tz($scope.selectedItem.value);
}else{
tempDate = moment.tz($scope.selectedItem.value);
}
$scope.formattedTime = tempDate.format('MMMM Do YYYY, h:mm:ss a');
$scope.$apply();
}
$scope.updateTime();
setInterval(function () {
$scope.updateTime()
}, 1000);
});