当前位置:网站首页>时间对象的格式化
时间对象的格式化
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;
}
},
边栏推荐
- 【Verilog基础】PPA优化问题总结(含面积优化、速度优化)
- 【Pytorch】学习笔记(一)
- 2022杭电多校六 1009-Map (巴那赫不动点)
- (2022牛客多校四)A-Task Computing (排序+动态规划)
- redis集群redis-trib扩容缩容
- 51nod 2882最短路 (树链剖分)
- makefile automatically compiles C files in directories and subdirectories
- [YOLOv5] 6.0 environment construction (updated from time to time)
- Master-slave delay reason and solution
- Introduction to Qt (4) - Continuous playback of pictures (the use of two timers)
猜你喜欢
随机推荐
redis集群redis-trib扩容缩容
动手写prometheus的exporter-01-Gauge(仪表盘)
meta learning
二叉树 层次遍历 及例题
Button Wizard Delete File Command
MySQL 高级知识【 MyISAM 读锁写锁限制】
mysql 高级知识【order by 排序优化】
A preliminary study on the use of ndk and JNI
PHP 类函数和对象函数
用模态框 实现 注册 登陆
MES对接Simba实现展讯平台 IMEI 写号与耦合测试
php 将时间戳转化为 刚刚、几分钟前、几小时前、几天前 格式
51nod 1706 最短路 + 思维
ViewOverlay与ViewGroupOverlay
积性函数
【Bug解决】ValueError: Object arrays cannot be loaded when allow_pickle=False
一命令删除所有指定进程
(Codeforce 757)E. Bash Plays with Functions(积性函数)
设计分享|基于单片机的P0口驱动LED闪烁
postgresql源码学习(35)—— 检查点⑤-检查点中的XLog清理机制









