Functions required to deal with Date returned from MS ASP.NET MVC - Node.js Date

Node.js examples for Date:Date Calculation

Description

Functions required to deal with Date returned from MS ASP.NET MVC

Demo Code


function parseMSJSONString(data) {
    try {/*from   w  w w  .ja  v a  2  s  .c  om*/
        var newdata = data.replace(
            new RegExp('"\\\\\/Date\\\((-?[0-9]+)\\\)\\\\\/"', "g")
                        , "new Date($1)");
        newdata = eval('(' + newdata + ')');
        return newdata;
    }
    catch (e) { return null; }
}

Date.prototype.toMSJSON = function () {
    var date = '"\\\/Date(' + this.getTime() + ')\\\/"';
    return date;
};

Related Tutorials