sbt-idp/cope2n-fe/src/utils/time.ts
Viet Anh Nguyen eacd7fe5c5 Use GMT+8
2024-02-07 13:17:03 +07:00

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;
}