如何更改 Highstock 图表上的 UTC 时间戳?

How to change UTC timestamp on the Highstock charts?

我在 https://gmlews.com/api/data. And my code for highstock charts in http://jsfiddle.net/estri012/b5nhezLs/8/ 有一个 API 。

我的问题是我的时间戳看起来像这样“2020-03-15T11:46:10+07:00”。因此在图表上它应该显示 3 月 15 日 11:46 而不是 3 月 15 日 04:46。但图表显示 UTC 时间。如何修复它,让图表显示与我的本地相同的时间?图表上的最后三个数据显示的是 3 月 18 日而不是 3 月 19 日。在我的API中,最后三个数据必须是3月19日而不是3月18日。

$(function () {

$.getJSON('https://gmlews.com/api/data', function (data) {
console.log(data);
function format_two_digits(n) {
  return n < 10 ? '0' + n : n;
}
var accelero_x = [], timestamp = [];
  for (var i=0; i<data.length; i++){
  let inArr = [];
  inArr.push(Date.parse(data[i].timestamp));
  inArr.push(data[i].accelero_x);
    accelero_x.push(inArr);
    timestamp.push(data[i].timestamp);
 }
  console.log(accelero_x);
  console.log(timestamp);

    // Create the chart
    window.chart = new Highcharts.StockChart({
        chart: {
            renderTo: 'container'
        },

        rangeSelector: {
            inputEnabled: true,
                    buttons: [{
                        type: 'day',
                        count: 1,
                        text: '1D',
                    },
                    {
                        type: 'week',
                        count: 1,
                        text: '1W',
                    },
                    {
                        type: 'month',
                        count: 1,
                        text: '1M',
                    },
                    {
                        type: 'year',
                        count: 1,
                        text: '1Y',
                    }, {
                        type: 'all',
                        count: 1,
                        text: 'All',
                    }],
            inputDateFormat: '%d-%m-%Y',
            inputDateParser: function (value) {
                value = value.split('-');
                return Date.UTC(
                    parseInt(value[2]),
                    parseInt(value[1]) - 1,
                    parseInt(value[0])
                );
            },
        },

    title: {
    text: 'Accelero X'
},

xAxis: {
    type: "datetime",
  labels: {
        /* format: '{value:%Y-%m-%d}', */
        formatter: (currData) => {
          const currDate = new Date(currData.value);
          return format_two_digits(currDate.getHours()) + ':' + format_two_digits(currDate.getMinutes());
        },
        rotation: 45,
        align: 'left'
    }
},
series: [{
    name: 'Accelero X',
    data: accelero_x,
    type: 'spline',
    tooltip: {
        valueDecimals: 2
    }
}]
}, function (chart) {

        // apply the date pickers
        setTimeout(function () {
            $('input.highcharts-range-selector', $('#' + chart.options.chart.renderTo)).datepicker();
        }, 0)
    });
});


// Set the datepicker's date format
$.datepicker.setDefaults({
    dateFormat: 'dd-mm-yy',
    beforeShow: function() {
      var date = $(this).val().split('-');
        $('input.highcharts-range-selector').datepicker("setDate", new Date(parseFloat(date[0]), parseFloat(date[1]) - 1, parseFloat(date[2])));
    },
    onSelect: function (dateText) {
        this.onchange();
        this.onblur();
    }
});

});

尝试将 time.useUTC 设置为 false - https://api.highcharts.com/highcharts/time.useUTC

演示:http://jsfiddle.net/BlackLabel/avhw7km8/

  time: {
    useUTC: false
  },