March 3, 2011

Convert JSON Date to Standard Date Format

Many peoples asked about JSON date conversion into Javascript code or Jquery
Code. The method is very simple and easy. When ever you insert Date into
database using Json and when you retrieve that date from database its in Json
Format which is some thing like that:

My input Date is : 14/2/2011 (for example)
My output Date is : /Date(1297246301973)/ (for example)

So here problems create when u update that date into database again its cause error.
Here's is simple code to formulate the actual date as you inserted before

var date = /Date(1297246301973)/;
var parsedDate = new Date(parseInt(date.substr(6)));
var newDate = new Date(parsedDate);

var getMonth = newDate.getMonth();
var getDay = newDate.getDay();
var getYear = newDate.getYear();

var standardDate = getMonth + '/' + getDay + '/' + getYear;

Now you got your date according to you format....:)

4 comments:

  1. Thanks... it resolved my problem.

    ReplyDelete
  2. thank's man. it is useful.

    ReplyDelete
  3. You may have a few companions that are keen on setting you up with a companion or relative whom they believe is simply ideal for you yet do whatever it takes not to consent to go on an arranged meet up that is set up by somebody who doesn't have any acquaintance with you well overall.http://znajdzlove.pl/

    ReplyDelete
  4. I have checked this link this is really important for the people to get benefit from. UN38.3 standard

    ReplyDelete