Fix timeformat
This commit is contained in:
parent
722ad16e3c
commit
9d5b3bc2c0
@ -15,6 +15,7 @@ import { useParams } from 'react-router-dom';
|
||||
import { downloadReport } from 'request/report';
|
||||
import styled from 'styled-components';
|
||||
import { SheetViewer } from "react-office-viewer";
|
||||
import { datetimeStrToDate } from 'utils/time';
|
||||
|
||||
export interface ReportFormValues {
|
||||
dateRange: [Dayjs, Dayjs];
|
||||
@ -127,13 +128,13 @@ const ReportDetail = () => {
|
||||
<Typography.Title level={5}>
|
||||
Start date:{' '}
|
||||
<span style={{ fontWeight: '400' }}>
|
||||
{report_data?.metadata?.start_at.split('T')[0]}
|
||||
{datetimeStrToDate(report_data?.metadata?.start_at, 'Asia/Singapore')}
|
||||
</span>
|
||||
</Typography.Title>
|
||||
<Typography.Title level={5}>
|
||||
End date:{' '}
|
||||
<span style={{ fontWeight: '400' }}>
|
||||
{report_data?.metadata?.end_at.split('T')[0]}
|
||||
{datetimeStrToDate(report_data?.metadata?.end_at, 'Asia/Singapore')}
|
||||
</span>
|
||||
</Typography.Title>
|
||||
</HeaderContainer>
|
||||
|
@ -1,4 +1,7 @@
|
||||
export function datetimeStrToDate(dateTimeStr: string, targetTimeZone: string): string {
|
||||
if (!dateTimeStr) {
|
||||
return "";
|
||||
}
|
||||
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('-');
|
||||
|
Loading…
Reference in New Issue
Block a user