Convert DateTime To JSON DateTime

前端 未结 7 1114

I have a WebService which return DateTime Field.

I get a result /Date(1379048144000)/ but

i want just 1379048144000 how can i ach

7条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-16 22:11

    There are two solutions:

    1. client side:

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

    It is possible to need alsou to convert into data object var date = new Date(xxx)

    1. Server side:

      Newtonsoft.Json.JsonConvert.SerializeObject(your_object)
      

提交回复
热议问题