javascript - angular js date input formatting -
i trying create date input in angularjs app , have trouble formatting date. have created plnkr illustrate issue:http://plnkr.co/edit/lbqipg?p=preview
my issue regardless of date format receiving sql server (i put 2 sample dates in plnkr 2013-07-11t00:00:00.000 , 2013-07-11), javascript date object applying time zone code , affecting display of date in input field displaying 07/10/2013 instead of correct date of 7/11/2013. want date returned database, don't want timezone applied @ all, date relevant me, not time. need create custom directive accurately display date want getting iso date time , assigning date string input? or there better solution. here sample of code thinking might need use format date in directive:
var newdate = $scope.databasedata.mydate.toisostring(); newdate = new date(newdate); $scope.databasedata.mydate= new date((newdate.getutcmonth() +1) + "/" +newdate.getutcdate() + "/" + newdate.getutcfullyear());
angularjs uses iso8601 spec date , time. need shift timezone if want javascript parse iso8601 string correctly.
however if create date object this
$scope.thing1 = new date(2013, 6, 11); (month 0 based.)
this dumped thu jul 11 2013 00:00:00 gmt-0400 (eastern daylight time)
in console.
the date object automatically picks time zone , render correctly 07/11/2013.
Comments
Post a Comment