3

How to convert datetime variable to string in JavaScript?

2
  • 1
    What kind of datetime variable? JavaScript has no such data type, only a Date object. Commented Mar 10, 2011 at 14:20
  • i passed date object while rendering i got serialization problem in view page.i cant able to get correct date format.i got a result as /Date(1281067200000),but i want result as 8/6/2010? Commented Mar 11, 2011 at 5:58

3 Answers 3

4

I've had a lot of success with Datejs. It took away a lot of pain.

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

Comments

3

I have no idea what kind of DateTime variable you're talking about, so I'll assume you're talking about Date:

var stringVal = someDateVar.toString();

Comments

3
var stringrepresentation = datetimevalue.toString();

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.