2

Possible Duplicate:
How do I output an ISO-8601 formatted string in Javascript?

I am trying to convert a date and time input to an ISO format but I am getting .toISOString is undefined? I have to be missing something silly.

var startDate = "10/11/2012";
var startTime = "12:12:00";

var fullDate = startDate + " " + startTime;
var fullDateReal = new Date(fullDate);

var iso = fullDateReal.toISOString();

Why would .toISOString() show as undefined?

I need to end up with the ISO format ("2012-10-11T12:12") timezone is optional.

Update It looks like this problem is because IE8 does not support this. So how could I go about converting my inputs to the format listed?

Community
  • 1
  • 1
Adam
  • 3,615
  • 6
  • 32
  • 51

1 Answers1

1

Some browsers don't support ECMAScript 5 (which is required for toISOString).

http://kangax.github.com/es5-compat-table/

Matthew Blancarte
  • 8,251
  • 2
  • 25
  • 34
  • I saw this after my comment above. That makes sense as to why it's not working. So then how would be a good way to convert to the format I need? – Adam Oct 11 '12 at 17:22
  • See this other SO answer: http://stackoverflow.com/questions/2573521/how-do-i-output-an-iso-8601-formatted-string-in-javascript – Matthew Blancarte Oct 11 '12 at 17:24
  • Cool this answered the main question of why it was not working and posed the correct alternative. Thanks. – Adam Oct 11 '12 at 17:26