I have a angular-strap bootstrap datepicker
<input id="dp5" class="span8" type="text" ng-model="obj.date" data-date-format="mm/dd/yyyy"  placeholder="Pick a Date" bs-datepicker>
The backend is a Spring MVC REST application which originally returns the date in milliseconds (java.util.Date). The date I receive from the above datepicker element is in the following format
2013-10-01T06:00:00.000Z
How can I convert it to milliseconds so that I can properly ship it to the backend?
As I know you can create directive to handle it:
Demo Plunker
app.directive('datetimez', function() {
    return {
        restrict: 'A',
        require : 'ngModel',
        link: function(scope, element, attrs, ngModelCtrl) {
          element.datetimepicker({
            dateFormat:'dd/MM/yyyy hh:mm:ss',
            language: 'pt-BR'
          }).on('changeDate', function(e) {
            var outputDate = new Date(e.date);
           var n = outputDate.getTime();
           ngModelCtrl.$setViewValue(n);
            scope.$apply();
          });
        }
    };
});
And HTML wrapper for date-picker should be like:
  <div id="date" class="input-append" datetimez ng-model="var1">
So after date change var1 gets milliseconds (see Demo)
Hope this direction will help
You can call Date.parse function on the string:
Date.parse("2013-10-01T06:00:00.000Z") // 1380607200000
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With