2

I have a date in the form of:

"2012-10-11T00:00:00"

The date is returned from a ASP.NET Webservice as part of a JOSN object. How can I convert this date format to a Javascript date object and also write the date as follows to the screen:

11/10/2012

Thanks

Liron Harel
  • 10,819
  • 26
  • 118
  • 217

2 Answers2

4
var myDate = new Date("2012-10-11T00:00:00".replace(/T/," "));
var myDateString = myDate.getDate() + "/" + (myDate.getMonth() + 1) + "/" + myDate.getFullYear()
ic3b3rg
  • 14,629
  • 4
  • 30
  • 53
2

For date conversions I use a plugin

date.js

Be sure to include all the jquery files needed, there is plenty of documentation on how to implement this

If you do not want to use a plugin check this out http://msdn.microsoft.com/en-us/library/ie/ff743760(v=vs.94).aspx

Or this overflow answer

Community
  • 1
  • 1
CR41G14
  • 5,464
  • 5
  • 43
  • 64