Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taobao-mini-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qinhaitao
taobao-mini-template
Commits
f2a2c3ad
Commit
f2a2c3ad
authored
Jan 21, 2021
by
qinhaitao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:
🎸
获取年份等api
parent
5a987d7c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletion
+15
-1
date.ts
v2.0/src/utils/common/date.ts
+15
-1
No files found.
v2.0/src/utils/common/date.ts
View file @
f2a2c3ad
...
...
@@ -20,6 +20,13 @@ const EIGHT_HOURS = 8 * 60 * 60 * 1000
* getTimestamp 时间戳
* getStartTimestamp 某天开始的时间戳
* getEndTimestamp 某天结束的时间戳
* getYear 获取年份
* getMonth 获取月份
* getDay 获取天
* getHour 获取小时
* getMinute 获取分钟
* geSecond 获取秒数
* getMillisecond 获取毫秒
* }
*/
export
function
formatDate
(
date
:
string
|
number
=
Date
.
now
())
{
...
...
@@ -28,6 +35,13 @@ export function formatDate(date: string | number = Date.now()) {
format
:
(
template
=
'YYYY-MM-DD'
)
=>
dayjs
(
beijingDate
).
format
(
template
),
getTimestamp
:
()
=>
(
typeof
date
===
'number'
?
date
:
dayjs
(
date
).
valueOf
()
-
EIGHT_HOURS
),
getStartTimestamp
:
()
=>
getStartTimestamp
(
dayjs
(
beijingDate
).
format
(
'YYYY/MM/DD'
)),
getEndTimestamp
:
()
=>
getEndTimestamp
(
dayjs
(
beijingDate
).
format
(
'YYYY/MM/DD'
))
getEndTimestamp
:
()
=>
getEndTimestamp
(
dayjs
(
beijingDate
).
format
(
'YYYY/MM/DD'
)),
getYear
:
()
=>
dayjs
(
beijingDate
).
get
(
'year'
),
getMonth
:
()
=>
dayjs
(
beijingDate
).
get
(
'month'
),
getDay
:
()
=>
dayjs
(
beijingDate
).
get
(
'day'
),
getHour
:
()
=>
dayjs
(
beijingDate
).
get
(
'hour'
),
getMinute
:
()
=>
dayjs
(
beijingDate
).
get
(
'minute'
),
geSecond
:
()
=>
dayjs
(
beijingDate
).
get
(
'second'
),
getMillisecond
:
()
=>
dayjs
(
beijingDate
).
get
(
'millisecond'
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment