angular-ui / bootstrap

PLEASE READ THE PROJECT STATUS BELOW. Native AngularJS (Angular) directives for Bootstrap. Smaller footprint (20kB gzipped), no 3rd party JS dependencies (jQuery, bootstrap JS) required. Please read the README.md file before submitting an issue!
http://angular-ui.github.io/bootstrap/
MIT License
14.29k stars 6.73k forks source link

unix timestamp from server and back also as timestamp #6477

Closed peckomingo closed 7 years ago

peckomingo commented 7 years ago

If get a timestamp from the server and then want to display the date for the user in "yy-mm-dd" format also when he changes the date. However, when he sends the form the date should ge send as timestamp again.

I tried to accomplish this with $parsers and my code looks something like this. `var parseDate = function(value) {

if(value instanceof Date) {
    var timestamp = value.getTime();
    return timestamp;
} else return "";

}; ngModel.$parsers.push(parseDate);`

But the date gets send as something like 2017-02-19T23:00:00.000Z in the network tab.

Is there anything wrong with the plugin and handling timestamps?

wesleycho commented 7 years ago

This library does not support strings for the model - please convert it to a date object when binding to ng-model as per docs for datepicker.