js-time-string
v0.0.5
Published
时间格式处理
Downloads
3
Readme
介绍
js时间转换工具
引用
import timeString from 'js-time-string'
时间转换
console.log(timeString._getTimes("stamp")); console.log(timeString._getTimes()); console.log(timeString._getTimes("yyyy-M")); console.log(timeString._getTimes("yyyy-MM")); console.log(timeString._getTimes("yyyy-M-d")); console.log(timeString._getTimes("yyyy-MM-dd")); console.log(timeString._getTimes("yyyy-M-d H:m:s")); console.log(timeString._getTimes("yyyy-MM-dd HH:mm:ss")); console.log(timeString._getTimes("H:m:s")); console.log(timeString._getTimes("HH:mm:ss")); console.log(timeString._getTimes("yyyy",1632905389000)); console.log(timeString._getTimes("yyyy-M",1632905389000)); console.log(timeString._getTimes("yyyy-MM",1632905389000)); console.log(timeString._getTimes("yyyy-M-d",1632905389000)); console.log(timeString._getTimes("yyyy-MM-dd",1632905389000)); console.log(timeString._getTimes("yyyy-M-d H:m:s",1632905389000)); console.log(timeString._getTimes("yyyy-MM-dd HH:mm:ss",1632905389000)); console.log(timeString._getTimes("H:m:s",1632905389000)); console.log(timeString._getTimes("HH:mm:ss",1632905389000));
计算两个时间差
console.log(timeString._difference(['2021-09-29 16:49:49','2021-10-20 16:49:49'])); console.log(timeString._difference([1632905389000,1635497389000])); console.log(timeString._difference(['2022-02-22 16:49:49'])); console.log(timeString._difference([1632905389000]));
获取某个时间前或者后几天时间
console.log(timeString._timeFrame('')); console.log(timeString._timeFrame('',3)); console.log(timeString._timeFrame('2021-09-29 16:49:49',3)); console.log(timeString._timeFrame('2021-09-29 16:49:49',-3)); console.log(timeString._timeFrame('2021-09-29 16:49:49',0)); console.log(timeString._timeFrame(1653814189000,1)); console.log(timeString._timeFrame(1653814189000,-1)); console.log(timeString._timeFrame(1653814189000,0));