throrin19 edited a comment on issue #14453:
URL: https://github.com/apache/echarts/issues/14453#issuecomment-800163920


   I found how to resolve this with `date-fns-tz` :  
   
   I force the dateTime in UTC but converted in specific timezone using 
function `utcToZonedTime`. And with that, all showed dates are correctly showed 
in specific timezone without any problems : 
   
   ```js
   import { utcToZonedTime, format } from 'date-fns-tz';
   
   const timezone = 'America/Boise';
   const time = [
       1615868012847,
       1615889612847,
   ];
   
   const data = [
       // data array with [time, value] items
   ];
   
   const options = {
       xAxis   : {
           type        : 'time',
           min         : utcToZonedTime(time[0], timezone),
           max         : utcToZonedTime(time[1], timezone),
       },
       tooltip : {
           trigger     : 'axis',
           confine     : true,
           axisPointer : {
               animation   : false,
               label       : {
                   formatter({ value }) {
                       // used to already show datetime completelly
                      return format(value, 'yyyy-MM-dd HH:mm:ss', { timeZone : 
timezone });
                   },
               },
           },
       },
       series : [{
           type : 'line',
           name : 'test',
           data : data.map(item => [utcToZonedTime(item[0], timezone) 
,item[1]]),
       }],
   };
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to