6 lines
399 B
TypeScript
6 lines
399 B
TypeScript
![]() |
export function datetimeStrToDate(dateTimeStr: string, targetTimeZone: string): string {
|
||
|
const options: Intl.DateTimeFormatOptions = { timeZone: targetTimeZone, year: 'numeric', month: '2-digit', day: '2-digit' };
|
||
|
const date = new Date(dateTimeStr);
|
||
|
const convertedDateTimeStr = date.toLocaleDateString('en-US', options).split('/').reverse().join('-');
|
||
|
return convertedDateTimeStr;
|
||
|
}
|