sbt-idp/cope2n-fe/src/utils/time.ts

6 lines
399 B
TypeScript
Raw Normal View History

2024-02-07 06:17:03 +00:00
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;
}