Friday 7 October 2016

Convert JSON Date to Standard Date Format in asp.net

Convert JSON Date to Standard Date Format in asp.net

Description:

In this example we explain that how to convert JSON date to normal date in asp.net or convert JSON return date to asp.net date and time format.

Many developers have a question like convert JSON date conversion into JavaScript code or JQuery
Code. Whenever you insert Date into Database using JSON format and when you retrieve that date from database it’s in JSON Format which is something like that:



My input Date is: 10/3/2016 (for example)
My output Date is: /Date (10854246301573)/ (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(10854246301573)/;
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;

1 comments:

  1. I was trying this long time thanks bro.
    It's very useful for me thanks.

    ReplyDelete