1

I'm working on angular based app and i have a really strange bug.. When i use:

<input type="date" ng-model="date">

the $scope.date has one day delay...

When I try to run the attachment code it prints the date which I have selected but with one day delay :(
What can I do?!

Thank you :)

var app = angular.module('app', []);

app.controller('ctrl', ['$scope', function($scope){
}])
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>


<body ng-app="app">
  <body ng-controller="ctrl">
    <input type="date" ng-model="date">
    {{ date }}
      
    </body>
  </body>
Ahmet Karakaya
  • 9,899
  • 23
  • 86
  • 141
Yehuda
  • 1,382
  • 3
  • 18
  • 25

2 Answers2

0

The code is working fine. The result is displaying in yyyy-mm-dd format.

Eric Hotinger
  • 8,957
  • 5
  • 36
  • 43
aneeshraj
  • 101
  • 1
  • 9
0

I think it is similar this issue : Jquery Datepicker off by one day

I have solved by using momentjs library. It provides lots of time-zone methods.

moment.utc([year, month, day])._d
Community
  • 1
  • 1
scokmen
  • 571
  • 3
  • 19