{"action":"created","issue":{"url":"https://api.github.com/repos/angular-ui/bootstrap/issues/4554","labels_url":"https://api.github.com/repos/angular-ui/bootstrap/issues/4554/labels{/name}","comments_url":"https://api.github.com/repos/angular-ui/bootstrap/issues/4554/comments","events_url":"https://api.github.com/repos/angular-ui/bootstrap/issues/4554/events","html_url":"https://github.com/angular-ui/bootstrap/issues/4554","id":110500388,"number":4554,"title":"Angular-UI date picker is in invalid state when given a specified date format while the ng-model has a string value as “yyyy-MM-ddThh:mm:ssZ”","user":{"login":"Jiran","id":1455200,"avatar_url":"https://avatars.githubusercontent.com/u/1455200?v=3","gravatar_id":"","url":"https://api.github.com/users/Jiran","html_url":"https://github.com/Jiran","followers_url":"https://api.github.com/users/Jiran/followers","following_url":"https://api.github.com/users/Jiran/following{/other_user}","gists_url":"https://api.github.com/users/Jiran/gists{/gist_id}","starred_url":"https://api.github.com/users/Jiran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jiran/subscriptions","organizations_url":"https://api.github.com/users/Jiran/orgs","repos_url":"https://api.github.com/users/Jiran/repos","events_url":"https://api.github.com/users/Jiran/events{/privacy}","received_events_url":"https://api.github.com/users/Jiran/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/angular-ui/bootstrap/labels/component:%20datepicker","name":"component: datepicker","color":"ffffff"},{"url":"https://api.github.com/repos/angular-ui/bootstrap/labels/resolution:%20invalid","name":"resolution: invalid","color":"e6e6e6"},{"url":"https://api.github.com/repos/angular-ui/bootstrap/labels/resolution:%20support","name":"resolution: support","color":"c7def8"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-08T17:10:54Z","updated_at":"2015-10-08T20:20:41Z","closed_at":"2015-10-08T18:24:10Z","body":"I am getting my date value from Mongoose as \"2015-10-08T00:00:00Z\" and when this is binded to the angular-ui datepicker, the form filed is shown as \"ng-invalid\". It seems as though when grabbing the date from the model it comes back as a string when datepicker is searching for a date object. This StackOverflow words the question better than myself and shows the issue. \r\n\r\nhttp://stackoverflow.com/questions/33017677/angular-ui-date-picker-is-in-invalid-state-when-specified-the-date-format-as-d\r\n\r\nIt also has a solution from user, Chet, I don't know his Github handle but the solution is below \r\n\r\n```\r\nangular.module('test')\r\n.config(['$httpProvider', function ($httpProvider) {\r\n\r\n    // ISO 8601 Date Pattern: YYYY-mm-ddThh:MM:ss\r\n    var dateMatchPattern = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}/;\r\n\r\n   var convertDates = function (obj) {\r\n      for (var key in obj) {\r\n         if (!obj.hasOwnProperty(key)) continue;\r\n\r\n         var value = obj[key];\r\n         var typeofValue = typeof (value);\r\n\r\n         if (typeofValue === 'object') {\r\n            // If it is an object, check within the object for dates.\r\n            convertDates(value);\r\n         } else if (typeofValue === 'string') {\r\n            if (dateMatchPattern.test(value)) {\r\n               obj[key] = new Date(value);\r\n            }\r\n         }\r\n      }\r\n   }\r\n\r\n   $httpProvider.defaults.transformResponse.push(function (data) {\r\n      if (typeof (data) === 'object') {\r\n         convertDates(data);\r\n      }\r\n\r\n      return data;\r\n   });\r\n}])\r\n```\r\n\r\nI just wanted to report this bug and hopefully help a few more people find the solution as I've spent 2 days trying to figure it out."},"comment":{"url":"https://api.github.com/repos/angular-ui/bootstrap/issues/comments/146674845","html_url":"https://github.com/angular-ui/bootstrap/issues/4554#issuecomment-146674845","issue_url":"https://api.github.com/repos/angular-ui/bootstrap/issues/4554","id":146674845,"user":{"login":"Jiran","id":1455200,"avatar_url":"https://avatars.githubusercontent.com/u/1455200?v=3","gravatar_id":"","url":"https://api.github.com/users/Jiran","html_url":"https://github.com/Jiran","followers_url":"https://api.github.com/users/Jiran/followers","following_url":"https://api.github.com/users/Jiran/following{/other_user}","gists_url":"https://api.github.com/users/Jiran/gists{/gist_id}","starred_url":"https://api.github.com/users/Jiran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jiran/subscriptions","organizations_url":"https://api.github.com/users/Jiran/orgs","repos_url":"https://api.github.com/users/Jiran/repos","events_url":"https://api.github.com/users/Jiran/events{/privacy}","received_events_url":"https://api.github.com/users/Jiran/received_events","type":"User","site_admin":false},"created_at":"2015-10-08T20:20:40Z","updated_at":"2015-10-08T20:20:40Z","body":"@icfantv Cool thanks for sharing the DateParser, I am still new to Angular so I am trying to figure it out, solid point and why the solution above may not be the best. However, may I ask you how exactly do I use the uibDateParser? Do I just run all of my Date models through the parser as such? \r\n\r\n```\r\nuibDateParser($scope.model.dateObj)\r\n```\r\n\r\nThanks for your help nonetheless! :) "}}