Dynamically change the date formats

Hi there,

Would you kindly help us for dynamically changing the date format?
Now I’m trying to switch the date format according to the each view by the below 4 periods but the different date format hasn’t been applied there.

↓ For example, when the initial period was “3 days” as above,
if I clicked the below “2 weeks” button, the format for 2 weeks isn’t applied correctly.
(It’s the same one with the initial date format)

Date formats:

switch(days) {
 case 3: // For 3 days
  scheduler1.second_scale.x_date = '%F, %j(%D)';
  break;
 case 14: // For 2 weeks
  scheduler1.second_scale.x_date = '%n/%j';
  break;
}

scheduler1.setCurrentView(currentDate, 'timeline')

Would you have any good tips for this case?

Thank you for your many helps in advance.

meicom

Hello @meicom,

Likely the issue is connected with the case, that you are changing second_scale of the scheduler, as this property exists only in the timeline config:

 scheduler.createTimelineView({
    name:   "timeline",
    ...
    second_scale:{
        x_unit: "day",
        x_date: "%F %d"
    }

so it should be just defined in the config of views you are using, like follows:

// First timeline
 scheduler.createTimelineView({
    name:   "timeline_1",
    ...
    second_scale:{
        x_unit: "day",
        x_date: "%F %d"
    }
// Second timeline
 scheduler.createTimelineView({
    name:   "timeline_2",
    ...
    second_scale:{
        x_unit: "week",
        x_date: "%w"
    }

Here is a demo:
https://snippet.dhtmlx.com/za4gjnel

If it’s not your case, could you please reproduce the issue in the demo above(open the demo => reproduce the issue => click the “Save” button => send me the new link)?

Kind regards,

1 Like

Hello Siarhei,

Thank you for your kind support.
I arranged the settings above more, and then it has work well on my end.
Much appreciated!! :raised_hands:

Thank you for your cooperation despite your busy schedule.

meicom

1 Like