当前位置:网站首页>时间对象的格式化
时间对象的格式化
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;
}
},
边栏推荐
猜你喜欢
sess.restore() 和 tf.import_meta_graph() 在使用时的一些关联
微信小程序错误 undefined Expecting ‘STRING‘,‘NUMBER‘,‘NULL‘,‘TRUE‘,‘FALSE‘,‘{‘,‘[‘, got ]解决方案
2022杭电多校六 1009-Map (巴那赫不动点)
C语言中指针的介绍
二叉树 层次遍历 及例题
Use Mongoose populate to implement multi-table associative storage and query, with complete code included
08 Spark on RDD 依赖关系
【Bug解决】ValueError: Object arrays cannot be loaded when allow_pickle=False
【Pytorch】学习笔记(一)
[GYCTF2020]Ezsqli-1|SQL注入
随机推荐
MES对接Simba实现展讯平台 IMEI 写号与耦合测试
微信小程序 wx:for 循环输出 例子
Codeforces Round #738 (Div. 2) E
机器学习建模高级用法!构建企业级AI建模流水线
ABP中的数据过滤器
Qt入门(五)——文件操作、热键和鼠标的读取(txt窗口的实现)
A preliminary study on the use of ndk and JNI
第二课:概率论
2022杭电多校六 1009-Map (巴那赫不动点)
力扣每日一题-第50天-383. 赎金信
微信小程序错误 undefined Expecting ‘STRING‘,‘NUMBER‘,‘NULL‘,‘TRUE‘,‘FALSE‘,‘{‘,‘[‘, got ]解决方案
弹出PopupWindow后让背景变暗的方法
Hand-written prometheus exporter-01-Gauge (dashboard)
(nowcoder22529C)dinner(容斥原理+排列组合)
PHP 正则给img的src添加域名
C语言中指针的介绍
13 Spark on RDD 全局累加器
【Verilog基础】关于芯片中信号串扰的理解
stm32使用spi1在slave 模式下 dma 读取数据
14 Spark on RDD 广播变量