当前位置:网站首页>时间对象的格式化
时间对象的格式化
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;
}
},
边栏推荐
- Share | design based on MCU P0 mouth to drive the LED flashing
- sess.restore() 和 tf.import_meta_graph() 在使用时的一些关联
- (2022牛客多校五)B-Watches(二分)
- -Wl,--start-group ... -Wl,--end-group for resolving circular dependencies of several libraries
- PHP regular to img SRC to add the domain name
- 洛谷P4197 Peaks 线段树合并
- 使用Mongoose populate实现多表关联存储与查询,内附完整代码
- 一命令删除所有指定进程
- 跨域请求浏览器无法显示set-cookie,坑了我一晚上
- 记录一些 PostgreSQL问题分析思路
猜你喜欢

洛谷P4197 Peaks 线段树合并

STM8L LCD digital tube driver, thermometer LCD display

Qt入门(五)——文件操作、热键和鼠标的读取(txt窗口的实现)
![[PP-YOLOv2] Training a custom dataset](/img/f5/90fb1a4b6096f77755f566a6acbf0a.png)
[PP-YOLOv2] Training a custom dataset
![WeChat applet error undefined Expecting 'STRING','NUMBER','NULL','TRUE','FALSE','{','[', got ]Solution](/img/31/a9b0c31f648d41e300949ac43c5cab.png)
WeChat applet error undefined Expecting 'STRING','NUMBER','NULL','TRUE','FALSE','{','[', got ]Solution

二叉树 层次遍历 及例题

【CUDA】版本自由切换

RecyclerView的多选模式

2021 RoboCom 世界机器人开发者大赛-本科组(决赛)7-4猛犸不上 Ban(最短路)

(2022牛客多校五)G-KFC Crazy Thursday(二分+哈希/Manacher)
随机推荐
牛客多校2 G League of Legends
(codeforce547)C-Mike and Foam(质因子+容斥原理)
启牛商学院靠不靠谱呢?证券账户开了安全吗
Modal dialog is used to implement the sign-in
小程序banner图展示
Binary tree level traversal and examples
A preliminary study on the use of ndk and JNI
postgresql源码学习(35)—— 检查点⑤-检查点中的XLog清理机制
(Codeforce 757)E. Bash Plays with Functions(积性函数)
MES对接Simba实现展讯平台 IMEI 写号与耦合测试
第二课:概率论
Manacher(求解最长回文子串)
动手写prometheus的exporter-01-Gauge(仪表盘)
(2022牛客多校四)D-Jobs (Easy Version)(三维前缀或)
Qt入门(四)——连续播放图片(两种定时器的运用)
【瑞吉外卖】day04:员工分页查询、启用/禁用员工账号、编辑员工信息
【latex异常与错误】There were undefined references.Reference `xxx‘ on page x undefined.参考引用公式编号时发生错误
(2022杭电多校六)1010-Planar graph(最小生成树)
ABP中的数据过滤器
2022杭电多校六 1007-Shinobu loves trip(同余方程)