当前位置:网站首页>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
边栏推荐
猜你喜欢
HyperMotion云迁移助力中国联通,青云完成某央企上云项目,加速该集团核心业务系统上云进程
HyperMotion云迁移完成阿里云专有云产品生态集成认证
教育行业云迁移最佳实践:海云捷迅使用HyperMotion云迁移产品为北京某大学实施渐进式迁移,成功率100%
PySide2
OpenStack命令操作
什么是云迁移?云迁移的四种模式分别是?
Storage path of mod subscribed by starbound Creative Workshop at Star boundary
Logback logger and root
Installation and use of postman pit
剑指offer刷题(2)--面向华为
随机推荐
HyperBDR云容灾V3.2.1版本发布|支持更多云平台,新增监控告警功能
DP - [noip2000] grid access
微信小程序将原生请求通过es6的promise来进行优化
krpano全景之vtour文件夹和tour
在电视屏幕上进行debug调试
解决ssh配置文件优化以及连接慢的问题
Use the executors class to quickly create a thread pool
PySide2
Request module
编译Openssl
SED 学以致用
Quickly understand the three ways of thread implementation
Some experience of using dialogfragment and anti stepping pit experience (getactivity and getdialog are empty, cancelable is invalid, etc.)
某政务云项目业务系统迁移调研实践
进入新公司,运维工程师从下面这几项了解系统的部署
js 抛物线运动方法封装
返回数组排序后下标
void*是怎样的存在?
elk安装
RecyclerView高级使用(一)-侧滑删除的简单实现