0

How can I convert a date from:
Thu, 1 July 2011 22:30:00 to '2011-07-01T13:51:50.417' using javascript.

I get the UTC format when I do a new date.

IE causes me issues when I first create a date object as it shows: NaN

0

3 Answers 3

1

You could generate a new Date-Object and then get the different parts:

var today = new Date();
var year = today.getFullYear(); // Returns 2012
var month = today.getMonth()+1; // Returns the month (zero-based)
...

Then you can create a new string like you need it.

Sign up to request clarification or add additional context in comments.

Comments

0

possible duplicate try search next time stackoverflow question
Try http://www.datejs.com/. It is a JavaScript Date Library with an extended Date.parse method and a Date.parseExact method, which lets you specify a format string. See DateJS APIDocumentation.

and then you can manipulate it as you want

Comments

0

The d3.js library has some very solid routines for date conversions. See https://github.com/mbostock/d3/wiki/Time-Formatting#wiki-parse.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.