Struggling to properly format a date variable and pass it to the Eonasdan datetimepicker for Angular, but no matter what attempts are made, a deprecation warning is received:
Deprecation warning: moment construction falls back to JS Date. This is discouraged and will be removed in an upcoming major release. For more information, refer to https://github.com/moment/moment/issues/1407. Arguments:
Several methods have been attempted:
Date from AJAX - Wed, 05 Jul 2017 00:00:00 GMT
/*example1*/
angular.forEach(tickets, function(value, key){
$scope.startDate = new Date(value.start_date);
$scope.endDate = new Date(value.end_date);
});
/*example2*/
angular.forEach(tickets, function(value, key){
$scope.startDate = moment(startDate, "YYYY-MM-DD");
$scope.endDate = moment(value.end_date, "YYYY-MM-DD");
});
Here are the datetimepicker options:
$scope.calendarWidgetOptions = {
format: 'YYYY-MM-DD',
minDate: moment().startOf('d')
};
Despite trying various solutions, the deprecation warning persists and the date may not display correctly in certain browsers/timezones.