json - Get ui.bootstrap.datepicker value without time/timezone -


i need able store selected date value date without time in ng-model.

here view:

<script type="text/ng-template" id="form_field_datetime">   <h3 style="color:coral ;">{{field.displayname}}</h3>   <br />   <div>     <div ng-controller="datectrl">         <p class="input-group">           <input type="text" class="form-control" datepicker-popup="{{format}}" is-open="opened" ng-required="true" ng-model="field.thevalues[0]" />           <span class="input-group-btn">             <button type="button" class="btn btn-default" ng-click="open($event)"><i class="glyphicon glyphicon-calendar"></i></button>           </span>          </p>     </div>     </div> </script> 

enter image description here

on selection of date shown above stored value in ng-model :

2012-03-12t22:00:00.000z 

i need:

2012-03-13 

here controller(pretty in example):

  app.controller('datectrl', ['$scope',        function ($scope) {         $scope.open = function($event) {           $event.preventdefault();           $event.stoppropagation();            $scope.opened = true;         };          $scope.dateoptions = {           formatyear: 'yy',           startingday: 0         };          $scope.formats = ['yyyy-mm-dd', 'dd-mmmm-yyyy', 'yyyy/mm/dd', 'dd.mm.yyyy', 'shortdate'];         $scope.format = $scope.formats[0];        }   ]); 

how go around this?

i have used directive mentioned earlier in comments of question handle selected date , remove time info.

<script type="text/ng-template" id="form_field_date">   <h3 style="color:coral ;">{{field.displayname}}</h3>   <br />   <div>     <div ng-controller="datectrl">         <p class="input-group">           <input datepicker-localdate type="text" class="form-control" datepicker-popup="{{format}}" is-open="opened" ng-required="true" ng-model="field.thevalues[0]" />           <span class="input-group-btn">             <button type="button" class="btn btn-default" ng-click="open($event)"><i class="glyphicon glyphicon-calendar"></i></button>           </span>          </p>     </div>     </div> </script> 

controller(datectrl):

   app.controller('datectrl', ['$scope',        function ($scope) {         $scope.open = function($event) {           $event.preventdefault();           $event.stoppropagation();            $scope.opened = true;         };          $scope.dateoptions = {           formatyear: 'yy',           startingday: 0         };          $scope.formats = ['yyyy-mm-dd', 'dd-mmmm-yyyy', 'yyyy/mm/dd', 'dd.mm.yyyy', 'shortdate'];         $scope.format = $scope.formats[0];        }   ]); 

the directive(datepicker-localdate):

app.directive('datepickerlocaldate', ['$parse', function ($parse) {     var directive = {         restrict: 'a',         require: ['ngmodel'],         link: link     };     return directive;      function link(scope, element, attr, ctrls) {         var ngmodelcontroller = ctrls[0];          // called javascript date object when picked datepicker         ngmodelcontroller.$parsers.push(function (viewvalue) {             console.log(viewvalue);console.log(viewvalue);console.log(viewvalue);             // undo timezone adjustment did during formatting             viewvalue.setminutes(viewvalue.getminutes() - viewvalue.gettimezoneoffset());             // want local date in iso format             return viewvalue.toisostring().substring(0, 10);         });     } }]); 

it works now!


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -