first commit
This commit is contained in:
commit
e8ec46d19f
60 changed files with 13652 additions and 0 deletions
22
src/utils/datetime.ts
Normal file
22
src/utils/datetime.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import 'moment/dist/locale/th';
|
||||
import moment from 'moment';
|
||||
|
||||
moment.locale('th');
|
||||
|
||||
export function setLocale(locale: string) {
|
||||
moment.locale(locale);
|
||||
}
|
||||
|
||||
export function dateFormat(
|
||||
date?: string | Date | null,
|
||||
fullmonth = false,
|
||||
time = false,
|
||||
) {
|
||||
const m = moment(date);
|
||||
|
||||
if (!m.isValid()) return '';
|
||||
|
||||
const month = m.format(fullmonth ? 'MMMM' : 'MMM');
|
||||
|
||||
return m.format(`DD ${month} YYYY ${time ? ' HH:mm' : ''}`);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue