2024-02-07 06:17:03 +00:00
|
|
|
export function datetimeStrToDate(dateTimeStr: string, targetTimeZone: string): string {
|
2024-02-07 07:08:25 +00:00
|
|
|
if (!dateTimeStr) {
|
|
|
|
return "";
|
|
|
|
}
|
2024-02-07 06:17:03 +00:00
|
|
|
const options: Intl.DateTimeFormatOptions = { timeZone: targetTimeZone, year: 'numeric', month: '2-digit', day: '2-digit' };
|
|
|
|
const date = new Date(dateTimeStr);
|
2024-03-05 09:15:59 +00:00
|
|
|
const convertedDateTimeStr = date.toLocaleDateString('en-US', options).split('/').reverse();
|
|
|
|
return convertedDateTimeStr[0] + "-" + convertedDateTimeStr[2] + "-" + convertedDateTimeStr[1];
|
2024-02-07 06:17:03 +00:00
|
|
|
}
|