博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
日期时间格式化方法,可以格式化年、月、日、时、分、秒、周
阅读量:4520 次
发布时间:2019-06-08

本文共 1267 字,大约阅读时间需要 4 分钟。

1 Date.prototype.Format = function (formatStr) { 2     var week = ['日', '一', '二', '三', '四', '五', '六']; 3     return formatStr.replace(/yyyy|YYYY/, this.getFullYear()) 4                   .replace(/yy|YY/, (this.getYear() % 100) > 9 ? (this.getYear() % 100).toString() : '0' + (this.getYear() % 100)) 5                   .replace(/MM/, (this.getMonth() + 1) > 9 ? (this.getMonth() + 1).toString() : '0' + (this.getMonth() + 1)).replace(/M/g, (this.getMonth() + 1)) 6                   .replace(/w|W/g, week[this.getDay()]) 7                   .replace(/dd|DD/, this.getDate() > 9 ? this.getDate().toString() : '0' + this.getDate()).replace(/d|D/g, this.getDate()) 8                   .replace(/HH|hh/g, this.getHours() > 9 ? this.getHours().toString() : '0' + this.getHours()).replace(/H|h/g, this.getHours()) 9                   .replace(/mm/g, this.getMinutes() > 9 ? this.getMinutes().toString() : '0' + this.getMinutes()).replace(/m/g, this.getMinutes())10                   .replace(/ss/g, this.getSeconds() > 9 ? this.getSeconds().toString() : '0' + this.getSeconds()).replace(/S|s/g, this.getSeconds());11 };

将毫秒转化成日期方法:

eval("new " + data.Rows[i].Occurdt.split('/')[1]).Format("yyyy-MM-dd HH:mm:ss")

 

转载于:https://www.cnblogs.com/zhangwei595806165/p/3281988.html

你可能感兴趣的文章
Android通过泛型简化findViewById类型转换
查看>>
swift
查看>>
eclipse maven 插件的安装和配置
查看>>
mysql基本知识总结
查看>>
php的zend引擎执行过程 一
查看>>
pycharm 快捷键
查看>>
Linux常用命令
查看>>
AutoFac IoC DI 依赖注入
查看>>
.net中的设计模式---单例模式
查看>>
安装程序工具 (Installutil.exe)22
查看>>
python 学习(pip工具的安装)
查看>>
博客园在我的博客添加点击小心心特效
查看>>
如何简单解释 MapReduce算法
查看>>
微软Office Online服务安装部署(二)
查看>>
从 0 到 1 实现 React 系列 —— 1.JSX 和 Virtual DOM
查看>>
面向接口编程详解(二)——编程实例
查看>>
解决java.lang.NoClassDefFoundError: org/apache/log4j/Level
查看>>
端口号
查看>>
mysql for macOS安装
查看>>
iOS中的KeyChain的用途
查看>>