mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-25 11:40:04 +08:00
16 lines
343 B
TypeScript
16 lines
343 B
TypeScript
import * as moment from 'moment';
|
|
|
|
// eslint-disable-next-line import/prefer-default-export
|
|
export function formatDate(
|
|
value: moment.Moment | undefined | null,
|
|
format: string | string[] | undefined,
|
|
): string {
|
|
if (!value) {
|
|
return '';
|
|
}
|
|
if (Array.isArray(format)) {
|
|
format = format[0];
|
|
}
|
|
return value.format(format);
|
|
}
|