start_date format

Hi, I have a question about parse the date though JSON to gantt.
I have a date variable, which is in the formate ‘yyyy-mm-dd’~
But when I want to parse it to start_date field, I have to change it to ‘dd-mm-yyyy’, or it will not appear correctly…but actually, what it appear on the gantt chart, the formate is ‘yyyy-mm-dd’

Any idea of how to parse my variable without changing the format?? cuz I have large data to parse, don’t want to change format for each of them… thanks ~~^_^

Hi,
you can change the expected date format using this config
docs.dhtmlx.com/gantt/api__gantt … onfig.html

The point is, I parse the data through controller class through a JSONGenerator:
for(Task__c t : projectList)
{
counter++;
generator.writeStartObject(); //Write the starting marker of a JSON object ‘{’
generator.writeStringField(‘id’, string.valueOf(counter));
generator.writeStringField(‘text’, t.Name);
** generator.writeDateField(‘start_date’,t.Start_Date__c);
generator.writeNumberField(‘duration’,10);
generator.writeEndObject(); //Write the end marker of a JSON object ‘}’
}
jsonString = generator.getAsString();
Then in my apex page:
var task={!jsonString};
gantt.parse(task,“json”);

the line with ** has the date formate like 2015-01-04…so I have to change it here?
change it to ‘01-04-2015’…

can’t use the gantt.config for this case write?

I’m not sure I understand the question.
Your generator serializes the dates in a certain format, and the client-side also has some expected date format.
If these two formats does not match - dates won’t be loaded correctly.
As a solution - you can change one of those formats - either tell generator to use a format that is expected by the client-side, or tell the client side to expect the format that is used by a generator.
The expected client-side format can be changed by a config from my previous post

yea~~
I want to tell the client side to expect a new format, but what the link you post shows that I first should declare my date variables, which I can’t get through the client side…

Here is the code in my client:
var task={!jsonString};
function displayChart()
{
gantt.init(“gantt_here”);
gantt.parse(task,“json”);
}

I tried
String xml_date;
var task={!jsonString};
function displayChart()
{ gantt.config.xml_date="%Y-%m-%d %H:%i";
gantt.init(“gantt_here”);
gantt.parse(task,“json”);
}
but it doesn’t work~

Hi Aliaksandr, I understand what’s your suggestion here ~
so I did this:

function displayChart()
{
gantt.config.start_date="%Y-%m-%d";
gantt.config.scale_unit = “week”;
var task={!jsonString};
gantt.init(“gantt_here”);
gantt.parse(task,“json”);
}

the config.scale_unit shows well in my page, but the date, still didn’t change…

Oh…solved ~~~~thanks ~~~~^_^