mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-15 21:16:17 +02:00
add new date format utility function
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
import dayjs from 'dayjs';
|
||||||
|
import utc from 'dayjs/plugin/utc';
|
||||||
|
|
||||||
|
dayjs.extend(utc);
|
||||||
|
|
||||||
|
export const formatDate = {
|
||||||
|
toLocalDate: (date: string, format: string = 'YYYY-MM-DD') => dayjs(date).format(format),
|
||||||
|
toLocalDateTime: (date: string) => dayjs(date).toDate(),
|
||||||
|
toUTCDate: (date: string, format: string = 'YYYY-MM-DD') => dayjs(date).utc().format(format),
|
||||||
|
toUTCDateTime: (date: string) => dayjs(date).utc().toDate(),
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user