【问题标题】:How can I change date formats "2022-06-04T00:00:00.000Z" to "1525844100000" for react highcharts如何将日期格式“2022-06-04T00:00:00.000Z”更改为“1525844100000”以响应高图表
【发布时间】:2022-06-10 19:31:18
【问题描述】:

我有以下日期:“2022-06-04T00:00:00.000Z”格式,我们需要以这种数字类型格式“1525844100000”的 highcharts 计算日期,所以我如何在 react-highcharts 中计算

xAxis: {
    type: 'datetime',
    ordinal: false,
    startOnTick: false,
    endOnTick: false,
    minPadding: 0,
    maxPadding: 0,
    Date: false,
    tickInterval: 4  3600  1000,
    minRange: 1  24  3600000,
    dateTimeLabelFormats: {
        day: '%l %P',
        hour: '%l %P'
    },
    offset: 0,
},

series: [
    {
        "data": [[1.424304e+12, 0.25]],
        color: '#FFA749',
    },
],

"highcharts": "^6.1.1", "react-highcharts": "^16.0.2",

我已经在上面给出了我的图表详细信息

【问题讨论】:

    标签: datetime charts highcharts datetimeoffset react-highcharts


    【解决方案1】:

    为了将ISO-8601转换为timestamp格式,使用getTime()JS方法。

    let timestamp = new Date('2022-06-04T00:00:00.000Z').getTime()
    // expected output: 1654300800000
    

    演示:https://jsfiddle.net/BlackLabel/vnLdum1k/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-14
      • 1970-01-01
      • 2011-04-06
      • 1970-01-01
      相关资源
      最近更新 更多