1

I'm using below code for date.

<input type="date" value="{{data.endDate | date: "MM/dd/yyyy"}}" ng-model="data.endDate" />

If i select today date (11/22/2015) in the controller the endDate value is 2015-11-21T18:30:00.000Z.

  1. How can i get exact selected date value?
  2. The model date is not displaying.
Prasad Kanaparthi
  • 6,423
  • 4
  • 35
  • 62
  • 1
    Possible duplicate of [Using AngularJS date filter with UTC date](http://stackoverflow.com/questions/20662140/using-angularjs-date-filter-with-utc-date) – GSerg Nov 22 '15 at 10:31

2 Answers2

1

This happens because, the date object for the selected date is created and is represented according to UTC standards.

Solution

  1. You will have to do a bit of temporal calculations in order to get the expected date value. Refer this article to understand the actual working to reach the desired goal.

  2. The simplest way, ones the date has been selected from the date picker, "convert the date object to a string using Date's locale convention method, dateObject.toLocaleDateString(). Refer this for further understanding.

example : $scope.dateOfTransactionFilter.toLocaleDateString()

Hope this helps. Cheers

Nishi Bangar
  • 720
  • 9
  • 20
0

Thanks nishi bangar,

The simplest way, ones the date has been selected from the date picker, "convert the date object to a string using Date's locale convention method, dateObject.toLocaleDateString(). Refer this for further understanding.