当前位置:网站首页>JS format time
JS format time
2022-04-23 14:16:00 【Ruirui junior】
export default function dateFormat(fmt, date) {
// Date conversion
let ret;
const opt = {
"Y+": date.getFullYear().toString(), // year
"m+": (date.getMonth() + 1).toString(), // month
"d+": date.getDate().toString(), // Japan
"H+": date.getHours().toString(), // when
"M+": date.getMinutes().toString(), // branch
"S+": date.getSeconds().toString() // second
// If there are other formatting character requirements, you can continue to add , Must be converted to a string
};
for (let k in opt) {
ret = new RegExp("(" + k + ")").exec(fmt);
if (ret) {
fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
};
};
return fmt;
}
call
DateFormat('YY-mm-dd HH:MM:SS', new Date()),
版权声明
本文为[Ruirui junior]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231408339383.html
边栏推荐
猜你喜欢
Win10 comes with groove music, which can't play cue and ape files. It's a curvilinear way to save the country. It creates its own aimpack plug-in package, and aimp installs DSP plug-in
使用Executors类快速创建线程池
Jira截取全图
ThreadGroup ThreadGroup implémente l'interface threadfactory en utilisant la classe Introduction + Custom thread Factory
線程組ThreadGroup使用介紹+自定義線程工廠類實現ThreadFactory接口
金融行业云迁移实践 平安金融云整合HyperMotion云迁移解决方案,为金融行业客户提供迁移服务
进入新公司,运维工程师从下面这几项了解系统的部署
微信小程序客服接入,实现发送和接收消息
什么是云迁移?云迁移的四种模式分别是?
Use the executors class to quickly create a thread pool
随机推荐
DP energy Necklace
On the multi-level certificate based on OpenSSL, the issuance and management of multi-level Ca, and two-way authentication
线程组ThreadGroup使用介绍+自定义线程工厂类实现ThreadFactory接口
处理 mkdir:无法创建目录“aaa“:只读文件系统
困扰多年的系统调研问题有自动化采集工具了,还是开源免费的
redis数据库讲解(四)主从复制、哨兵、Cluster群集
Logback logger and root
Gartner预测云迁移规模大幅增长;云迁移的优势是什么?
关于NodeJS中JSON5的相关配置和使用
文字组合,不重复,做搜索或查询关键字匹配
Pass in external parameters to the main function in clion
差分隐私(背景介绍)
mysql 5.1升级到5.67
MySQL数据库讲解(九)
JDBC和servlet写CRUD的接口总结
json date时间日期格式化
VMware installation 64 bit XP Chinese tutorial
多云数据流转?云上容灾?年前最后的价值内容分享
bc的用法
js 进度条,显示加载进度