Methods
dataPattern(str, formatopt) → {Date}
- Source:
将指定格式的字符串解析为日期字符串
Example
dataPattern("12-25-1995") // Mon Dec 25 1995 00:00:00 GMT+0800 (中国标准时间)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
str |
string | "12-25-1995" | ||
format |
string |
<optional> |
'-'
|
Returns:
Mon Dec 25 1995 00:00:00 GMT+0800 (中国标准时间)
- Type
- Date
dayOfYear(date) → {Number}
- Source:
当前日期天数
Example
dayOfYear(new Date()); // 250 当前new Date是20210907
Parameters:
Name | Type | Description |
---|---|---|
date |
Date |
Returns:
- Type
- Number
end()
- Source:
打印结束点
get_appoint_timestamp(str) → {String}
- Source:
获取指定时间戳
Example
get_appoint_timestamp("2019/10/24 08:00:00") // 1571875200000
get_appoint_timestamp("2019-10-24 08:00:00") // 1571875200000
Parameters:
Name | Type | Description |
---|---|---|
str |
String |
Returns:
时间戳
- Type
- String
get_current_timestamp() → {Number}
- Source:
获取当前时间戳
Example
get_current_timestamp() // 1630984496000
Returns:
当前时间戳
- Type
- Number
getColonTimeFromDate(date) → {*}
- Source:
返回当前24小时制时间的字符串
Example
getColonTimeFromDate(new Date()); // 11:37:45
Parameters:
Name | Type | Description |
---|---|---|
date |
* |
Returns:
- Type
- *
getDaysDiffBetweenDates(dateInitial, dateFinal) → {Number}
- Source:
返回日期间的天数
Example
getDaysDiffBetweenDates(new Date('2019-01-01'), new Date('2019-10-14')); // 286
Parameters:
Name | Type | Description |
---|---|---|
dateInitial |
Date | |
dateFinal |
Date |
Returns:
两个日期之间的相差天数
- Type
- Number
getDaysDiffBetweenDates(dateInitial, dateFinal) → {Number}
- Source:
如何获得两个日期之间的差异(以天为单位)?
Example
getDaysDiffBetweenDates(new Date('2017-12-13'), new Date('2017-12-22')) // 9
Parameters:
Name | Type | Description |
---|---|---|
dateInitial |
* | 日期1 |
dateFinal |
* | 日期2 |
Returns:
天数
- Type
- Number
isAfterDate(dateA, dateB, bORaopt) → {Boolean}
- Source:
检查是否在某日期 前 / 后
Example
isAfterDate(new Date(2010, 10, 21), new Date(2010, 10, 20), 'b'); // false
isAfterDate(new Date(2010, 10, 21), new Date(2010, 10, 20), 'a'); // true
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
dateA |
Date | 目标日期A | ||
dateB |
Date | 目标日期B | ||
bORa |
String |
<optional> |
'b'
|
在某日期 前(before) 还是 后(after) |
Returns:
- Type
- Boolean
nowInDateBetwen(d1, d2, date) → {Boolean}
- Source:
判断一个时间是否在两个时间范围内,返回true或false
Example
nowInDateBetwen("2019-01-01","2019-02-02","2019-01-02") // true
Parameters:
Name | Type | Description |
---|---|---|
d1 |
String | 时间范围1 |
d2 |
String | 时间范围2 |
date |
String | 时间 |
Returns:
- Type
- Boolean
start()
- Source:
打印开始点
tomorrow() → {String}
- Source:
获取明天的字符串格式时间
Example
今天是2021-09-07
tomorrow(); // 2021-09-08
Returns:
明天日期
- Type
- String