locked
JSON date format problem RRS feed

  • Question

  • User-2059141420 posted

    I'm getting my data onto my page, but I'm having some trouble with the JSON data while returning Date data types.

    I'm getting a string back that looks like this:

    /Date(1224043200000)/

    Saturday, January 12, 2019 1:54 PM

Answers

  • User-552477072 posted

    Hi

    You can do like following.

     function ToJavaScriptDate(value) { //In value you put the string you got
    var pattern = /Date\(([^)]+)\)/;
    var results = pattern.exec(value);
    var dt = new Date(parseFloat(results[1]));
    return (dt.getMonth() + 1) + "/" + dt.getDate() + "/" + dt.getFullYear();
    }

    Please don't forget to mark as answer if it helps you. Thanks!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, January 12, 2019 2:09 PM