angularjs - Persist Angular UI Bootstrap Datepicker as string to API -
i'm using angular-ui-datepicker popup , i'm trying persist saved date value string date only. m/d/yyyy
the input after date selection correct 5/11/2015
value stored date
mon may 11 2015 00:00:00 gmt-0400 (eastern daylight time) 12:00am
is there way store value date string
, not date
object?
<p class="input-group"> <input type="text" datepicker-popup="m/d/yyyy" ng-model="event.date" is-open="datepickers['date']" class="form-control" /> <span class="input-group-btn"> <button type="button" class="btn btn-default" ng-click="toggledatepicker('date', $event)"> <i class="fa fa-calendar"></i> </button> </span> </p>
in above case need data date string, instance:
{ date: '5/11/2015' }
and not
{ date: `mon may 11 2015 00:00:00 gmt-0400 (eastern daylight time) 12:00am` }
i don't think there's simple (standard) javascript date formatting function, guess build m/d/yyyy string using example:
getdate() // returns date getmonth() // returns month getfullyear() // returns year
i've been messing around bit myself on various projects , might want consider date.toisostring. i've found angular automatically deserialize iso 8601 strings in json actual date object further use , vice versa it'll serialize date objects format transparently, don't have worry yourself.
Comments
Post a Comment