Tuya MiniApp Tools 版本信息:Node: v18.17.0 Tools: 0.6.6 Ray: 1.5.2
相关代码:
Code: Select all
const fetchLogs = async () => { try { const logs = await getAnalyticsLogsStatusLog({ devId: devInfo.devId, dpIds: '214', offset: 0, limit: 10, });
setLogs(logs.dps || []); const currentTime = new Date(); console.log(currentTime); console.log('logs:', logs); } catch (error) { console.error('Error fetching logs:', error); } };日志信息:
Code: Select all
"2024-07-24T07:33:35.788Z" { "dps": [ { "dpId": 214, "value": "wifi", "timeStamp": 1721705345, "timeStr": "2024-07-23 03:29:05" }, { "dpId": 214, "value": "ethernet", "timeStamp": 1721705366, "timeStr": "2024-07-23 03:29:26" }, { "dpId": 214, "value": "cellular", "timeStamp": 1721705407, "timeStr": "2024-07-23 03:30:07" }, { "dpId": 214, "value": "wifi", "timeStamp": 1721707636, "timeStr": "2024-07-23 04:07:16" }, { "dpId": 214, "value": "ethernet", "timeStamp": 1721707640, "timeStr": "2024-07-23 04:07:20" }, { "dpId": 214, "value": "wifi", "timeStamp": 1721709422, "timeStr": "2024-07-23 04:37:02" }, { "dpId": 214, "value": "ethernet", "timeStamp": 1721804351, "timeStr": "2024-07-24 06:59:11" }, { "dpId": 214, "value": "wifi", "timeStamp": 1721805229, "timeStr": "2024-07-24 07:13:49" }, { "dpId": 214, "value": "cellular", "timeStamp": 1721805296, "timeStr": "2024-07-24 07:14:56" }, { "dpId": 214, "value": "wifi", "timeStamp": 1721805500, "timeStr": "2024-07-24 07:18:20" } ], "hasNext": true, "dpc": [], "total": 1000 }
问题描述 调用该api获取数据,获取到的时间与实际时间不符
getAnalyticsLogsStatusLog 获取到的日期不对
-
- Posts: 114
getAnalyticsLogsStatusLog 获取到的日期不对
Last edited by silverlight on 2024年 Aug 2日 09:17, edited 2 times in total.
Tags:
Re: getAnalyticsLogsStatusLog 获取到的日期不对
获取到的时间与实际时间不符
===
指的是设备这个 dp 实际上报的时间和 timeStamp 或 timeStr 对不上吗?
-
- Posts: 114
Re: getAnalyticsLogsStatusLog 获取到的日期不对
是的,而且我也主动获取了本地时间,可以看出timeStamp 和timeStr 都跟实际时间相差很远
-
- Posts: 114
Re: getAnalyticsLogsStatusLog 获取到的日期不对
currentTime Thu Jul 25 2024 16:59:53 GMT+0800 (中国标准时间)这个时间是对的,json实际时间是这个"2024-07-25T08:59:53.683Z"。而 api获取的是这个{dpId: 214, value: 'ethernet', timeStamp: 1721897989, timeStr: '2024-07-25 08:59:49'}。是时区导致的吗?如何修改时区
Re: getAnalyticsLogsStatusLog 获取到的日期不对
timeStr 这里文案一般是设备配网所处的时区就决定了,如果要自行修改展示的时区或格式,建议采用 timeStamp 自行处理。