fix: format utc

master
guofei 2024-06-21 18:49:18 +08:00
parent 93242679a3
commit fa7e0b0964
3 changed files with 13 additions and 6 deletions

View File

@ -1,6 +1,6 @@
import { getUserByIdAPI } from '@/services/system/user'; import { getUserByIdAPI } from '@/services/system/user';
import { OrderPayType, OrderPayTypeStr, OrderStatus, UxOrderStatus, UxOrderStatusTag } from '@/utils/const'; import { OrderPayType, OrderPayTypeStr, OrderStatus, UxOrderStatus, UxOrderStatusTag } from '@/utils/const';
import { formatDateTime } from '@/utils/format'; import { formatDateTimeToUTC } from '@/utils/format';
import { AlipayCircleOutlined, WechatOutlined } from '@ant-design/icons'; import { AlipayCircleOutlined, WechatOutlined } from '@ant-design/icons';
import { ActionType } from '@ant-design/pro-components'; import { ActionType } from '@ant-design/pro-components';
import { Descriptions, Empty, Form, Modal, Spin, Table, Tabs } from 'antd'; import { Descriptions, Empty, Form, Modal, Spin, Table, Tabs } from 'antd';
@ -256,7 +256,7 @@ const UserDetailsModal = (props: PropTypes) => {
title: '扩容时间', title: '扩容时间',
dataIndex: 'createDate', dataIndex: 'createDate',
align: 'center', align: 'center',
render: (_, record: User.UserItemByInfo['dilatationLogs'][0]) => formatDateTime(record.createDate), render: (_, record: User.UserItemByInfo['dilatationLogs'][0]) => formatDateTimeToUTC(record.createDate),
}, },
{ {
title: '备注', title: '备注',

View File

@ -2,7 +2,7 @@ import { changeStatusAPI, delUxUserAPI, getUserListAPI } from '@/services/system
import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components'; import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components';
import { App, Button, Radio, Space, TableProps, message } from 'antd'; import { App, Button, Radio, Space, TableProps, message } from 'antd';
import { formatDateTime } from '@/utils/format'; import { formatDateTimeToUTC } from '@/utils/format';
import { useRef, useState } from 'react'; import { useRef, useState } from 'react';
import CreateModel from './CreateModule'; import CreateModel from './CreateModule';
import DilatationModel from './Dilatation'; import DilatationModel from './Dilatation';
@ -181,7 +181,7 @@ const Page = () => {
dataIndex: 'expired', dataIndex: 'expired',
align: 'center', align: 'center',
hideInSearch: true, hideInSearch: true,
renderText: (_, record: User.UserItem) => (!record.expired ? '-' : formatDateTime(record.expired)), renderText: (_, record: User.UserItem) => (!record.expired ? '-' : formatDateTimeToUTC(record.expired)),
}, },
{ {
title: '账户创建时间', title: '账户创建时间',
@ -189,14 +189,15 @@ const Page = () => {
align: 'center', align: 'center',
hideInSearch: true, hideInSearch: true,
renderText: (_, record: User.UserItem) => renderText: (_, record: User.UserItem) =>
!record.createdDateTime ? '-' : formatDateTime(record.createdDateTime), !record.createdDateTime ? '-' : formatDateTimeToUTC(record.createdDateTime),
}, },
{ {
title: '最后登录时间', title: '最后登录时间',
dataIndex: 'lastLoginTime', dataIndex: 'lastLoginTime',
align: 'center', align: 'center',
hideInSearch: true, hideInSearch: true,
renderText: (_, record: User.UserItem) => (!record.lastLoginTime ? '-' : formatDateTime(record.lastLoginTime)), renderText: (_, record: User.UserItem) =>
!record.lastLoginTime ? '-' : formatDateTimeToUTC(record.lastLoginTime),
}, },
{ {
title: '操作', title: '操作',

View File

@ -1,5 +1,7 @@
// @ts-ignore // @ts-ignore
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
dayjs.extend(utc);
// 示例方法,没有实际意义 // 示例方法,没有实际意义
export function trim(str: string) { export function trim(str: string) {
@ -9,3 +11,7 @@ export function trim(str: string) {
export const formatDateTime = (time: string) => { export const formatDateTime = (time: string) => {
return dayjs(time).format('YYYY-MM-DD HH:ss:mm'); return dayjs(time).format('YYYY-MM-DD HH:ss:mm');
}; };
export const formatDateTimeToUTC = (time: string) => {
return dayjs(time).utc().format('YYYY-MM-DD HH:ss:mm');
};