Search code examples
angularjsdjangodatetimedatetimepickerbootstrap-datetimepicker

How to get DateTime from JSON


How do I parse DateTime with Angular from my Django REST API? The date is stored in the following format 2016-07-07. Angular UI Datepicker does not recognize it a proper date format, so my field becomes blank when I load the form.


Solution

  • Oh. I just had to create a new Date object based on my JSON string.

    $scope.student.birth_date = new Date($scope.student.birth_date);