javascript - web api not receiving date from angularjs -


hi developing web application in angularjs. have 1 date in angularjs example 13-10-2017. in c# have below field

 public datetime licenseexpirydate { get; set; } 

when send 13-10-2017 in ajax request,licenseexpirydate accepts 0001-01-01. may know how fix this? can see angular date in dd-mm-yy format , c# date default format yyyy-mm-dd. tried convert yyyy-mm-dd below

 function formatdatedosetyymmdd(date) {                 debugger;                 var d = new date(date),                     month = '' + (d.getmonth() + 1),                     day = '' + d.getdate(),                     year = d.getfullyear();                  if (month.length < 2) month = '0' + month;                 if (day.length < 2) day = '0' + day;                  return [year,month, day].join('-');             } 

and returns nan-nan-nan appreciated. thank you.

you getting string in form dd-mm-yyyy on input, want turn string 3 numbers, , use in new date call

function formatdatedosetyymmdd(date) {      date = date.split('-').map(number);      var d = new date(date[2], date[1] - 1, date[0]),          month = '' + (d.getmonth() + 1),          day = '' + d.getdate(),          year = d.getfullyear();      if (month.length < 2) month = '0' + month;      if (day.length < 2) day = '0' + day;      return [year,month, day].join('-');  }  console.log(formatdatedosetyymmdd('13-10-2017'));


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -