封装日期时间自定义格式方法
来源:互联网 发布:长远汽配软件视频教程 编辑:程序博客网 时间:2024/05/03 07:03
export function parseTime(time, cFormat) { if (arguments.length === 0) { return null } const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}' let date if (typeof time === 'object') { date = time } else { if (('' + time).length === 10) time = parseInt(time) * 1000 date = new Date(time) } const formatObj = { y: date.getFullYear(), m: date.getMonth() + 1, d: date.getDate(), h: date.getHours(), i: date.getMinutes(), s: date.getSeconds(), a: date.getDay() } const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => { let value = formatObj[key] if (key === 'a') return ['一', '二', '三', '四', '五', '六', '日'][value - 1] if (result.length > 0 && value < 10) { value = '0' + value } return value || 0 }) return time_str }
阅读全文
0 0
- 封装日期时间自定义格式方法
- 自定义时间日期的格式
- ios 自定义时间日期格式
- android 对不同日期和时间的格式方法的封装
- NSDateFormatter setDateFormat 自定义日期/时间格式
- NSDateFormatter setDateFormat 自定义日期/时间格式
- 自定义 RMAN 显示的日期时间格式
- NSDateFormatter setDateFormat 自定义日期/时间格式
- 62.自定义日期格式/日期组件/时间戳
- js时间戳格式化成日期格式的多种方法
- DateTimePicker中自定义时间或日期显示格式
- DateTimePicker中自定义时间或日期显示格式
- DateTimePicker中自定义时间或日期显示格式
- DateTimePicker中自定义时间或日期显示格式
- DateTimePicker中自定义时间或日期显示格式
- DateTimePicker中自定义时间或日期显示格式
- C#支持从自定义日期时间格式到DateTime类型
- DateTimePicker中自定义时间或日期显示格式
- 【bzoj1783】[Usaco2010 Jan]Taking Turns
- 2017.11.3笔记
- Vuex核心概览
- 十一月三日课堂笔记
- st表
- 封装日期时间自定义格式方法
- Error:Unsupported method: BaseConfig.getApplicationIdSuffix().
- 概率图模型
- 【Redis笔记-10】Redis的设置数据库密码
- C#学习笔记:栈溢出异常(StackOverflowException)
- Win7上使用VM安装Max系统后如何使用网络
- LeetCode--Merge Two Sorted Lists(合并两个有序链表)Python
- java传引用还是传值的问题
- window下指定tomcat运行时的JDK