moment-timezone
moment-timezone copied to clipboard
conflict with moment.js in bootStrap dateTimepicker
i am using date time picker for getting both date and time from user and whenever i assign default date before adding moment-time zome it was working perfectly. but by the moment i included moment-timeZone in my project default date becomes UTC time and after every time i open calender/time dialogue it decrease number of hours which time zone is diferent from UTC e.g. i am working with time zone asia/karachi (UTC+05:00) and default time should be 2016-05-30 15:00 but it shows 2016-05-30 10:00 and after another change iteration of closing and opening widget drops it to 2016-05-30 5:00 and it happens for 5 time can any one please help. code is given below thanks in advance
$scope.$watch('scheduleJob', function () {
setTimeout(function () {
$('#datetimepicker').datetimepicker({
icons: {
time: "fa fa-clock-o",
date: "fa fa-calendar",
up: "fa fa-arrow-up",
down: "fa fa-arrow-down"
},
format: "YYYY-MM-DD, HH:mm",
defaultDate: moment(),
minDate: moment().subtract(1, 'day')
}).on('dp.change', function (e) {
$scope.croneExpression.timeZone = moment.tz.guess(e.date);
$scope.croneExpression.startDateTime = moment().year(e.date.year()).format("YYYY") + "-" + moment().month(e.date.month()).format("MM") + "-" + moment().date(e.date.date()).format("DD");
$scope.croneExpression.hour = e.date.hours();
$scope.croneExpression.minute = e.date.minutes();
});
$scope.croneExpression.timeZone = moment.tz.guess();
$scope.croneExpression.startDateTime = moment().year(moment().year()).format("YYYY") + "-" + moment().month(moment().month()).format("MM") + "-" + moment().date(moment().date()).format("DD");
$scope.croneExpression.hour = moment().hour();
$scope.croneExpression.minute = moment().minute();
}, 0);
});
+1
This is almost impossible to diagnose because the code sample is a mixture of Moment Timezone, an unknown version of Angular, and an unknown version of a date picker. If you have a small test case that shows that the bug is definitely in Moment Timezone, and not in the date picker library, then we can reopen this issue. But for now there's nothing we can fix.