json date to javascript date

json date string comes like below.

“/Date(1238540400000)/”

While I was developing I wanted convert into javascript date and get date in “mm/dd/yyyy” format.

The I am using below function to get it done.


function parseJsonDate(jsonDateString) {

var date; var newDate;
if (jsonDateString) {
date = new Date(parseInt(jsonDateString.replace('/Date(', '')));
newDate = date.getMonth() + 1 + '/' + date.getDate() + '/' + date.getFullYear();

 return newDate;
 }
}

I think this might help you….

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s