1.0.26 • Published 3 years ago
just-now-time v1.0.26
一些日期处理函数,主要处理为yyyy-mm-dd hh:mm:ss格式
🚀install
npm i -s just-now-time
🚀import
import { nowTime,formatTime,timeCn,whatDay,whatDayEn } from "just-now-time"
✨nowTime
获取当前时间,接收两个可选参数,用于替换默认间隔符号
nowTime()
nowTime(".", "/")
默认返回数据格式如下
{
date: "2021-12-22"
dateObj: {year: '2021', month: '12', day: '22'}
full: "2021-12-22 11:12:56"
time: "11:12:56"
timeObj: {hour: '11', minute: '12', second: '56'}
}
✨formatTime
格式化日期。接收三个参数,一参数必传,为日期,二三参数可选,替换默认间隔符号,不传参则默认返回当天日期格式化
formatTime() // 默认返回当天日期格式化
formatTime("Tue Aug 10 2021 20:23:59 GMT+0800 (GMT+08:00)")
formatTime("Tue Aug 10 2021 20:23:59 GMT+0800 (GMT+08:00)",".", "/") // 替换默认间隔符号
返回数据格式同nowTime
✨timeCn
格式化日期为 yyyy 年 m 月 d 日 h 时 m 分 s 秒形式,接受一个必传参数日期,不传参则默认返回当天日期格式化
timeCn() // 默认返回当天日期格式化
timeCn("Tue Aug 10 2021 20:23:59 GMT+0800 (GMT+08:00)")
返回数据格式如下
{
date: "2021年12月22日"
dateObj: {year: '2021年', month: '12月', day: '22日'}
full: "2021年12月22日 12时00分37秒"
time: "12时00分37秒"
timeObj: {hour: '12时', minute: '00分', second: '37秒'}
}
✨whatDay
获取该日期是星期几(中文),接收一个日期参数,不传参则默认返回今天星期几
whatDay() // 返回'星期二'
whatDay("Tue Aug 10 2021 19:23:53 GMT+0800 (GMT+08:00)") // 返回'星期二'
whatDayEn(1628598239000) // 返回'星期二'
✨whatDayEn
获取该日期是星期几(英文),接收一个日期参数,不传参则默认返回今天星期几
whatDayEn() // 返回'Tuesday'
// 搭配大写小转换函数
whatDayEn("2021-08-10").toUpperCase() // TUESDAY
whatDayEn("2021-08-10").toLowerCase() // tuesday
✨getDays
根据年月获取当月天数,和生成的日期数组
getDays("2021", "12")
返回数据格式如下
{
day: (31) [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
monthDay: (31) ['12-01', '12-02', '12-03', '12-04', '12-05', '12-06', '12-07', '12-08', '12-09', '12-10', '12- 11', '12-12', '12-13', '12-14', '12-15', '12-16', '12-17', '12-18', '12-19', '12-20', '12-21', '12-22', '12-23', '12-24', '12-25', '12-26', '12-27', '12-28', '12-29', '12-30', '12-31']
number: 31
yearMonthDay: (31) ['2021-12-01', '2021-12-02', '2021-12-03', '2021-12-04', '2021-12-05', '2021-12-06', '2021-12- 07', '2021-12-08', '2021-12-09', '2021-12-10', '2021-12-11', '2021-12-12', '2021-12-13', '2021-12-14', '2021-12- 15', '2021-12-16', '2021-12-17', '2021-12-18', '2021-12-19', '2021-12-20', '2021-12-21', '2021-12-22', '2021-12- 23', '2021-12-24', '2021-12-25', '2021-12-26', '2021-12-27', '2021-12-28', '2021-12-29', '2021-12-30', '2021-12- 31']
}
1.0.26
3 years ago
1.0.25
3 years ago
1.0.22
3 years ago
1.0.21
3 years ago
1.0.20
3 years ago
1.0.24
3 years ago
1.0.23
3 years ago
1.0.19
3 years ago
1.0.18
3 years ago
1.0.17
3 years ago
1.0.16
3 years ago
1.0.9
3 years ago
1.0.8
3 years ago
1.0.7
3 years ago
1.0.11
3 years ago
1.0.10
3 years ago
1.0.15
3 years ago
1.0.14
3 years ago
1.0.13
3 years ago
1.0.12
3 years ago
1.0.6
3 years ago
1.0.5
3 years ago
1.0.4
3 years ago
1.0.3
3 years ago
1.0.2
3 years ago
1.0.1
3 years ago
1.0.0
3 years ago