Use GMT+8

This commit is contained in:
Viet Anh Nguyen 2024-02-07 13:17:03 +07:00
parent 5ee6535985
commit eacd7fe5c5
2 changed files with 10 additions and 3 deletions

View File

@ -6,6 +6,7 @@ import React, { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { downloadReport } from 'request/report';
import { formatPercent, ensureMin, ensureMax } from 'utils/metric-format';
import { datetimeStrToDate } from 'utils/time';
const ReportTable: React.FC = () => {
@ -45,7 +46,7 @@ const ReportTable: React.FC = () => {
dataIndex: 'Created Date',
key: 'Created Date',
render: (_, record) => {
return <span>{record['Created Date'].toString().split('T')[0]}</span>;
return <span>{datetimeStrToDate(record['Created Date'], 'Asia/Singapore')}</span>;
},
width: 110,
},
@ -54,7 +55,7 @@ const ReportTable: React.FC = () => {
dataIndex: 'Start Date',
key: 'Start Date',
render: (_, record) => {
return <span>{record['Start Date'].toString().split('T')[0]}</span>;
return <span>{datetimeStrToDate(record['Start Date'], 'Asia/Singapore')}</span>;
},
width: 110,
},
@ -63,7 +64,7 @@ const ReportTable: React.FC = () => {
dataIndex: 'End Date',
key: 'End Date',
render: (_, record) => {
return <span>{record['End Date'].toString().split('T')[0]}</span>;
return <span>{datetimeStrToDate(record['End Date'], 'Asia/Singapore')}</span>;
},
width: 110,
},

View File

@ -0,0 +1,6 @@
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;
}