0

I am converting json date from something like:

/Date(1224043200000)/

to

Mon Oct 22 16:37:04 UTC+0800 2012

using

var date = new Date(parseInt(dateData.substr(6), 10));

Is there any way to change the format to just show the month, date and year (Oct 22, 2012) instead of including the timezone and current day using similar if not the same code as the one I'm already using? Thanks so much.

0

3 Answers 3

1

Checkout datejs which has powerful formatting capabilities. Using the toString FormatSpecifiers, you can provide a custom pattern like this:

new Date().toString("MMM dd yyyy");
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks, this worked for me. I have another question though, if I were to add the time here, should it be something like new Date().toString("MMM dd yyyy 00:00"); ? Or would the approach be different if the time were to be included? Sorry, I was told that we needed to show the time as well.
I figured it out. Thanks so much for the help.
Glad you figured that out. For everybody else: format specifiers can be looked here: code.google.com/p/datejs/wiki/FormatSpecifiers
0

You can try this:

var formattedDate = date.toString().split(" ").slice(1, 4).join(" ");

Comments

0

You may want to use momentjs With something like this :

moment(1224043200000).format("MMM Do, YYYY");

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.