Search code examples
jsondateazureutc

How do I convert JSON date to UTC date format for an Azure site?


When I deploy my site to Azure, All the dates that I get back from JSON are off by a day. I need help converting them to UTC format? I am in the EAST US.

My Date format in JSON

"DateEntered":"\/Date(1395115200000-0400)\/","DateReNegotiated":"\/Date(1401249600000-0400)\/","DateReceived":"\/Date(1395115200000-0400)\/","DateRequestComp":"\/Date(1395720000000-0400)\/","DisposDate":"\/Date(1399953600000-0400)\/"

How I currently convert them to readable dates:

var dr_date = $.date(inv.DateEntered);

Solution

  • I found a solution here, someone created a js file for different formats (including UTC):

    http://mvcworld.blogspot.com/2013/06/convert-json-date-to-javascript-date.html

    var de_date = inv.DateEntered; //$.date(inv.DateEntered);
    var d1_date = new Date(parseInt(de_date.substr(6)));
    var d2_date = d1_date.format("UTC:mm/dd/yyyy");