zoukankan      html  css  js  c++  java
  • 将序列化成json格式后日期(毫秒数)转成日期格式

        System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer(); 序列化

    //将序列化成json格式后日期(毫秒数)转成日期格式
            function ChangeDateFormat(cellval) {
                var date = new Date(parseInt(cellval.replace("/Date(", "").replace(")/", ""), 10));
                var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
                var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
                return date.getFullYear() + "-" + month + "-" + currentDate;
            }

    调用:ChangeDateFormat(json[i].PTime);

    如果是Newtonsoft.Json 则

     Newtonsoft.Json.Converters.IsoDateTimeConverter iso = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
                    iso.DateTimeFormat = "yyyy-MM-dd";
                    string json = JsonConvert.SerializeObject(dt, Formatting.Indented, iso);

    return JsonConvert.DeserializeObject<ApiResponse<T>>(strResult, new JsonSerializerSettings
                {
                    ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                });

  • 相关阅读:
    ftp
    vmware虚拟机如何安装ubuntu14.10系统
    第1章 初识java----Java简介
    fiddler
    Program Files 与Program Files (x86)
    跟我一起认识axure(三)
    React-FlipOver-Counter(日历翻页)
    vue2-vux-fitness-project
    cloud-music
    跟我一起认识axure(二)
  • 原文地址:https://www.cnblogs.com/nsky/p/3201560.html
Copyright © 2011-2022 走看看