当前位置:网站首页>时间对象的格式化
时间对象的格式化
2022-08-08 23:32:00 【聰籽】
value 时间戳
format 格式 'mm’到小时 'ss’到秒,不填默认返回到天
connector 连接符 不填默认为 ‘-’
{string}
timeFormat: function (value, format, connector) {
var date = new Date(value);
var yy = date.getFullYear();
var MM = date.getMonth() + 1;
var dd = date.getDate();
var hh = date.getHours();
var mm = date.getMinutes();
var ss = date.getSeconds();
var link = '-';
connector ? link = connector : link = '-';
if (MM < 10)
MM = "0" + MM;
if (dd < 10)
dd = "0" + dd;
if (hh < 10)
hh = "0" + hh;
if (mm < 10)
mm = "0" + mm;
if (ss < 10)
ss = "0" + ss;
if (format === 'mm') {
return "" + yy + link + MM + link + dd + " " + hh + ":" + mm;
} else if (format === 'ss') {
return "" + yy + link + MM + link + dd + " " + hh + ":" + mm + ":" + ss;
} else {
return "" + yy + link + MM + link + dd;
}
},
边栏推荐
- MySQL 高级知识【 MyISAM 读锁写锁限制】
- 2022牛客多校六 J-Number Game(简单推理)
- 51nod 2882最短路 (树链剖分)
- (2022杭电多校四)1001-Link with Bracket Sequence II(区间动态规划)
- Introduction to Qt (5) - file operation, hotkey and mouse reading (implementation of txt window)
- php convert timestamp to just, minutes ago, hours ago, days ago format
- (2022牛客多校三)A-Ancestor(LCA)
- 2022牛客多校六 M-Z-Game on grid(动态规划)
- Tp5 in cache cache, storage cell phone text message authentication code
- Small program figure display banner
猜你喜欢
MySQL 原理与优化,Group By 优化 技巧
2022牛客多校六 B-Eezie and Pie (dfs)
2022牛客多校六 A-Array(构造+哈夫曼)
51nod2884
牛客多校2 G League of Legends
【latex异常与错误】There were undefined references.Reference `xxx‘ on page x undefined.参考引用公式编号时发生错误
跨域请求浏览器无法显示set-cookie,坑了我一晚上
(2022杭电多校四)1001-Link with Bracket Sequence II(区间动态规划)
容斥原理
51nod2614 小B爱旅行 (参考范艺杰代码 基本抄袭 太难了)
随机推荐
Golang gorm 数据库连接,迁移,索引
可以在易方达基金上买基金吗,安全吗
【Verilog基础】关于芯片中信号串扰的理解
51nod2614 小B爱旅行 (参考范艺杰代码 基本抄袭 太难了)
Porting ucos2 code from stm32 to GD32
PHP闭包函数 bingTo的使用
牛客多校2 G League of Legends
用模态框 实现 注册 登陆
14 Spark on RDD 广播变量
Tp5 in cache cache, storage cell phone text message authentication code
(2022牛客多校三)A-Ancestor(LCA)
Low-Light Image Enhancement via a Deep Hybrid Network阅读札记
(2022牛客多校四)N-Particle Arts(思维)
Manacher(求解最长回文子串)
用工具实现 Mock API 的整个流程
(2022牛客多校五)G-KFC Crazy Thursday(二分+哈希/Manacher)
PHP 正则给img的src添加域名
LightningChart .NET 10.3.2 Crack 支持旧项目直接升级
小程序banner图展示
51nod1656 合并trie树