我是靠谱客的博主 轻松鲜花,这篇文章主要介绍json序列化后日期如何变回来,现在分享给大家,希望可以做个参考。

日期格式为

日期小于10的时候 占一位

比如 2019年9月1日

2015/9/1

function ChangeDateFormat(cellval) {
           var date = new Date(parseInt(cellval.replace("/Date(", "").replace(")/", ""), 10));
           var month =  date.getMonth() + 1;
           var currentDate =  date.getDate();
           return date.getFullYear() + "/" + month + "/" + currentDate;
       }
这里只是个人记录而已

yyyy/mm/dd

日期小于10的时候 占两位。个人推荐使用下面这一种方式去生成。

比如 2019年9月1日

2015/09/01

function ChangeDateFormat(cellval) {
          var date = new Date(parseInt(cellval.replace("/Date(", "").replace(")/", ""), 10));
          var month = date.getMonth() + 1;
          var currentDate = date.getDate();
          if (month < 10) {
              month="0"+month.toString();
          }
          if (currentDate < 10) {
              currentDate = "0" + currentDate.toString();
          }
          return date.getFullYear() + "/" + month + "/" + currentDate;
      }

转载于:https://www.cnblogs.com/jixinyu12345/p/4888831.html

最后

以上就是轻松鲜花最近收集整理的关于json序列化后日期如何变回来的全部内容,更多相关json序列化后日期如何变回来内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(46)

评论列表共有 0 条评论

立即
投稿
返回
顶部