Class: DateTool

tool. DateTool

时间工具类

new DateTool()

Methods


<static> currentDate()

获取当前日期对象
Returns:
当前日期对象
Type
Date

<static> currentDateString(format)

获取当前日期字符串
Parameters:
Name Type Description
format string 字符串格式
Returns:
当前日期字符串
Type
string

<static> currentTimeInterval()

获取当前时间戳
Returns:
当前时间戳
Type
number

<static> dateAfterDaysLater(beganDate, days)

获取(多态)日期某天后的日期()
Parameters:
Name Type Description
beganDate Date | string | number
days number
Returns:
目的日期
Type
Date

<static> dateFromDateString(dateString, format)

日期字符串转换日期 (待开发)
Parameters:
Name Type Description
dateString string 日期字符串
format string 日期格式
Since:
  • ~1.1.*
Returns:
日期
Type
Date

<static> dateFromTimeInterval(timeInterval)

时间戳转换日期
Parameters:
Name Type Description
timeInterval number 时间戳
Returns:
日期
Type
Date

<static> dateStringAfterDaysLater(beganDate, days)

获取(多态)日期某天后的日期字符串
Parameters:
Name Type Description
beganDate Date | string | number 开始日期
days number 天数
Returns:
目的日期字符串
Type
string

<static> dateStringFromDate(date, format)

日期转换日期字符串
Parameters:
Name Type Description
date Date Date对象
format string 格式化信息
Returns:
日期字符串
Type
string

<static> dateStringFromTimeInterval(timeInterval, format)

时间戳转换日期字符串
Parameters:
Name Type Description
timeInterval number 时间戳
format string 日期格式 如: yyyy-MM-dd hh:mm:ss
Returns:
日期字符串
Type
string

<static> distanceBetweenDate(startDate, endDate, justSeconds)

获取(多态)日期的距离
Parameters:
Name Type Description
startDate Date | string | number 起始日期
endDate Date | string | number 结束日期
justSeconds boolean 只需要秒的总数
Returns:
[秒,分,小时,天,月, 年]
Type
Array

<static> timeIntervalFromDate(date)

日期转换时间戳
Parameters:
Name Type Description
date Date 日期
Returns:
时间戳
Type
number

<static> timeIntervalFromDateString(dateString)

日期字符串转换时间戳 注:时间格式需满足Date规范 如 2017-05-23 18:56:00、2017/05/23
Parameters:
Name Type Description
dateString string 日期
Returns:
时间戳
Type
number

<static> transformDateStringByFormat(dateString, fromFormat, toFormat)

变换日期字符串格式 (待开发)
Parameters:
Name Type Description
dateString string 日期字符串
fromFormat string 输入格式
toFormat string 输出格式
Since:
  • ~1.1.*
Returns:
字符串
Type
string

<static> wantDate(_)

想要日期格式的日期
Parameters:
Name Type Description
_ Date | string | number 日期
Returns:
Type
Date

<static> wantTimeInterval(_)

想要时间戳格式的日期
Parameters:
Name Type Description
_ Date | string | number 日期
Returns:
Type
number

<static> weekDay(date)

获取指定(多态)日期为星期几
Parameters:
Name Type Description
date Date | string | number 日期
Returns:
0~6 星期一~星期日
Type
number