当前位置:网站首页>时间对象的格式化
时间对象的格式化
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;
}
},
边栏推荐
猜你喜欢
随机推荐
第二课:概率论
(2022杭电多校三)1011.Taxi(曼哈顿最值+二分)
Virtual router redundancy protocol VRRP - double-machine hot backup
LightningChart .NET 10.3.2 Crack 支持旧项目直接升级
mysql 高级知识【order by 排序优化】
官方一键安装redis集群
makefile automatically compiles C files in directories and subdirectories
php convert timestamp to just, minutes ago, hours ago, days ago format
小程序banner图展示
Share | design based on MCU P0 mouth to drive the LED flashing
设计分享|基于单片机的P0口驱动LED闪烁
记录一些 PostgreSQL问题分析思路
AsyncTask的替代方案
(2022牛客多校三)J-Journey(dijkstra)
循环神经网络实现股票预测
stm32 利用 串口接收空闲中断 + dma 实现不定长度dma 接收
2022杭电多校六 1009-Map (巴那赫不动点)
(newcoder 15079)无关(容斥原理)
(2022牛客多校三)A-Ancestor(LCA)
(2022杭电多校五)1010-Bragging Dice (思维)