gogessj4
gogessj4

Reputation: 89

Anychart ResourceGantt using Local Time

I'm using Anychart 8.1 in an Angular 5 project. We are creating a ResourceGantt POC at the moment. And when I'm creating items for the ResourceGantt I noticed that I create Local Time Date objects. But when I pass them as start & end parameters for the items on the datagrid they get transformed to UTC time, and the timeline also shows the data in UTC time. But we want it to be shown in local time. I couldn't find anything about it in the documentation. And I tried different things already using moment.js to transform the date in different types, but it always remain the same. Please any advice, cause this really is a breaking issue for us.

Upvotes: 1

Views: 492

Answers (2)

AnyChart Support
AnyChart Support

Reputation: 3905

You were right! anychart.format includes many useful functions to format dateTime, numbers and etc. Also, I may suggest you using the following approach to set the offset automatically:

var offset = new Date().getTimezoneOffset();
anychart.format.outputTimezone(offset);

Upvotes: 4

gogessj4
gogessj4

Reputation: 89

After some further looking into it I found out about the inputLocale(), outputLocale() & outputTimezone() functions. I fixed it by adding following line to my creation code:

anychart.format.outputTimezone(-60);

It looks like you have to tell the chart how far UTC is away from you instead how far you are away from UTC. But works like a charm now!

Upvotes: 1

Related Questions