19 lines
388 B
TypeScript
19 lines
388 B
TypeScript
export default function getInputDate(date: Date | string) {
|
|
|
|
if (!date)
|
|
return date;
|
|
if (typeof (date) === "string") {
|
|
date = new Date(date);
|
|
}
|
|
try {
|
|
|
|
return new Date(date.getTime() - new Date().getTimezoneOffset() * 60000).toISOString().substring(0, 19)
|
|
|
|
} catch {
|
|
|
|
return new Date(new Date().getTimezoneOffset() * 60000).toISOString().substring(0, 19)
|
|
|
|
}
|
|
|
|
}
|