2.0.7 • Published 2 years ago

@royalscome/format v2.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@royalscome/format

avatar Time formatting tool and number formatting tool

Install

$ npm i @royalscome/format

Usage

import { DateFormat } from "@royalscome/format";


DateFormat.format(new Date(), "yyyy年MM月dd日") // 2021年08月31日

// 具体使用介绍看下表(See the table below for detailed usage)

DateFormat

子类名介绍参数示例
format格式化日期(time=null,format="yyyy年MM月dd日"),time可传时间戳,标准时间格式,format为想获得的时间格式DateFormat.format(new Date(), "yyyy年MM月dd日") // 2021年08月31日
formatDateWithZero将日期格式化到当天零时(time)DateFormat.formatDateWithZero(new Date(), "yyyy年MM月dd日") // 2021年08月31日 00:00:00
formatDateWithLast将日期格式化到当天结束(time)DateFormat.formatDateWithLast(new Date(), "yyyy年MM月dd日") // 2021年08月31日 23:59:59
getDate将非标准格式日期转换为标准时间格式(time)DateFormat.getDate("2021.08.31") // 2021-08-31
getDateWithDot将标准时间格式转换为.形式(time)DateFormat.getDateWithDot("2021-08-31") // 2021.08.31
getNowYearAndMonth获取当前年和月(time)DateFormat.getNowYearAndMonth(new Date()) // 2021-8
getWeekDate获取当前星期几DateFormat.getWeekDate() // 星期三
getMonthWeek获取当前月份的第几周(time)
formatDateToRule格式化时间为今天显示具体时间,昨天显示昨天,昨天以前显示日期(time)具体看介绍
getDateToNumber根据传入数字可正负,得到日期(time=null,n)DateFormat.getDateToNumber(new Date(),-1) // 2021-08-30
compareDate比较时间大小(startTime, endTime)具体使用看介绍
getDiffDate计算时间差(startTime, endTime, fmt = "dd")具体使用看介绍
2.0.7

2 years ago

2.0.6

3 years ago

2.0.5

3 years ago

2.0.4

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.0

3 years ago