0

I have a reservation calendar, where I can click on day and time, so I open a bootstrap modal where there is a date input and a time input.

I'm using on the modal load with "date" parameter:

 $scope.calendarChosenDay = $filter('date')(new Date(date), 'yyyy-MM-dd');
 $scope.calendarChosenTime = $filter('date')(new Date(date), 'HH:mm');

When the modal opens, the date is correct, but the time is adding 2 hours because of timezone i guess.

What should I add to the filter, to take the current timezone like now its 1:40 pm it s giving me 3:40 pm, I want it to be 1:40. Any help?

georgeawg
  • 48,608
  • 13
  • 72
  • 95

1 Answers1

0

The code correctly shows dates in the current timezone:

angular.module("app",[])
.run(function($filter){
  var s = $filter('date')(new Date(), 'HH:mm');
  console.log(s);
})
<script src="//unpkg.com/angular/angular.js"></script>
<body ng-app="app"></body>

The problem is not with the code but the original source of the date variable.

georgeawg
  • 48,608
  • 13
  • 72
  • 95