当前位置:网站首页>Date formatting
Date formatting
2022-07-23 17:31:00 【No overtime at the front end】
var startTime = datePattern(new Date(searchForm.startTime), "yyyy-MM-dd") +
" 00:00:00";
export function datePattern (date, fmt) {
if (!date) return ''
if (!isValidDate(date)) return ''
var o = {
'M+': date.getMonth() + 1, // month
'd+': date.getDate(), // Japan
'h+': date.getHours() % 12 == 0 ? 12 : date.getHours() % 12, // Hours
'H+': date.getHours(), // Hours
'm+': date.getMinutes(), // branch
's+': date.getSeconds(), // second
'q+': Math.floor((date.getMonth() + 3) / 3), // quarter
'S': date.getMilliseconds() // millisecond
}
var week = {
'0': '\ Japan ',
'1': '\ One ',
'2': '\ Two ',
'3': '\ 3、 ... and ',
'4': '\ Four ',
'5': '\ 5、 ... and ',
'6': '\ 6、 ... and '
}
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
}
if (/(E+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? '\ star \ period ' : '\ Zhou ') : '') + week[date.getDay() + ''])
}
for (var k in o) {
if (new RegExp('(' + k + ')').test(fmt)) {
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
}
}
return fmt
}
Timestamps converted to HHMMSS
export function timestampToHHMMSS (value) {
var theTime = parseInt(value)// second
var theTime1 = 0// branch
var theTime2 = 0// Hours
if (theTime > 60) {
theTime1 = parseInt(theTime / 60)
theTime = parseInt(theTime % 60)
if (theTime1 > 60) {
theTime2 = parseInt(theTime1 / 60)
theTime1 = parseInt(theTime1 % 60)
}
}
边栏推荐
- Add dependent jar packages to the project in the idea
- 新零售电商平台怎么做?才能实现传统零售企业数字化转型?
- 程序员最想干的三件事 |漫画
- When does MySQL use table locks and row locks?
- 职场3道坎:年薪30万、50万、100万
- OpenIM重大优化-消息按需加载 一致性缓存 uniapp发布
- Food safety | ham sausage lunch meat, is it really so unbearable?
- Preliminary understanding of string
- Kubernetes Kubelet管理pod核心流程
- 详解一次SQL优化
猜你喜欢

食品安全|喝鲜奶可能感染结核病?带你了解什么是牛奶灭菌

Software configuration | Anaconda download, installation, environment configuration and uninstall

别再问我MySQL为啥没走索引?就这几种原因,全都告诉你

软件质量体系之思

unity之制作二维码扫描

When does MySQL use table locks and row locks?

记录一下MySql update会锁定哪些范围的数据

用pymysql封装项目通用的连接和查询

Software configuration | pychart download, installation, environment configuration and uninstall

食品安全|巧克力也有真假?关于它你了解多少
随机推荐
食品安全|听起来很健康的植物肉,是什么来头?
Pymoo学习 (3):使用多目标优化找到最优解的集合
isEmpty 和 isBlank 的用法区别,至少一半的人答不上来...
@Bean 注解的方法调用多次会创建多个bean 实例吗
转账业务追加日志(事务的传播行为).
[flask advanced] deeply understand the endpoint of flask routing from the source code
Software configuration | Anaconda download, installation, environment configuration and uninstall
LQR 控制学习-LQR控制 MATLAB官方教程-LQR 控制器_状态空间系统Matlab/Simulink建模分析
Food safety eating preserved eggs will lead poisoning? Don't worry about eating after knowing these points
SQL報錯盲注詳解
Food safety | drinking fresh milk may infect tuberculosis? Take you to know what is milk sterilization
Pymoo learning (3): use multi-objective optimization to find the set of optimal solutions
Food safety | eight things you must know when choosing probiotic products
Thoughts on software quality system
一加OnePlus 10T的一系列规格在产品发布前被披露
Major upgrade of openim - group chat reading diffusion model release group management function upgrade
How to set up the router correctly
js工具 cecp
大规模团队中的敏捷测试实践
文献学习(part100)--An Introduction to Autoencoders