-1

im sending datetime from controller to a jquery function. I want to display this ("13.06.2021") format but i have "2020-11-29T00:00:00" like this

how can i convert it ?

function forexample()
{
  $.ajax({
  .......
   succes : function(data) {
       alert(data[i].mydate); //i want "13.06.2021" format
  }
})
}
  • Please visit [help], take [tour] to see what and [ask]. But first ***>>>[Do some research, search for related topics on SO](https://www.google.com/search?q=javascript+format+date+site:stackoverflow.com)<< – mplungjan Jun 13 '21 at 05:47

1 Answers1

-1

You can get a JavaScript date object via:

d = new Date("2020-11-29T00:00:00")

Then get your desired format by getting the individual date components and creating a string from them.

// Month (0 is January)
d.getMonth() + 1

// Day
d.getDate()

// Year
d.getFullYear()
j3st
  • 315
  • 1
  • 8