Our pure JavaScript Scheduler component


Post by zivo13 »

Hi,

I'm using scheduler with mysql, in the startDate field of the db the date is set correctly ex: 2019-07-19 08:22:00 but in the scheduler it display at 2019-07-19 09:22:00

in the CrudManager.php i have this line:
private function convertDateToMx ($date) {
        
        $convertDate = new DateTime($date);
        $convertDate->setTimezone(new DateTimeZone('America/Mexico_City'));
        return $convertDate->format("Y-m-d H:i:s");
    }
And in the app.module.js
const _date = new Date();
_date.setHours(_date.getHours() - 1);  <-- this i intend to correct the offset but not working
Also i put a timeline that is showing a line at the current date/time and its working ok, so i'm lost here,

thanks and regards

Post by pmiklashevich »

Hello,

By default scheduler uses UTC to transfer/save dates. Dates will be automatically turned into a local time if zone info is present in the data. Similar question has been asked recently. Please see: viewtopic.php?f=44&t=10928#p62574

If you look at lib/Scheduler/model/TimeSpan.js you'll see what start/end dates format are:
https://www.bryntum.com/docs/scheduler/#Scheduler/model/TimeSpan#field-startDate
https://www.bryntum.com/docs/scheduler/#Scheduler/model/TimeSpan#field-endDate

Best regards,
Pavel

Pavlo Miklashevych
Sr. Frontend Developer


Post by zivo13 »

Thanks for the reply, but i dont have a problem with the date format, i have an issue with the timezone, like i said y the startDate the time is set in local time but in the scheduler shows an hour ahead, and as i state at the beginning, i declare the timezone, maybe with your answer its suppose to be resolved but i dont see it how

Post by pmiklashevich »

Please look at lib/Scheduler/model/TimeSpan.js:
/**
 * The start date of a time span (or Event / Task). Uses ISO 8601 date format by default (1962-06-17T09:21:34.125Z). To specify another
 * format, subclass TimeSpan and change the dateFormat
 * @field {String|Date} startDate
 */
{ name : 'startDate', type : 'date', dateFormat : 'YYYY-MM-DDTHH:mm:ssZ' },

/**
 * The end date of a time span (or Event / Task). Uses ISO 8601 date format by default (1962-06-17T09:21:34.125Z). To specify another
 * format, subclass TimeSpan and change the dateFormat
 * @field {String|Date} endDate
 */
{ name : 'endDate', type : 'date', dateFormat : 'YYYY-MM-DDTHH:mm:ssZ' },
If you pay attention of how date format is specified, you'll see Z in the string 'YYYY-MM-DDTHH:mm:ssZ'. This "Z" means that timezone is taken into account.

If you return "2018-05-21 08:00" from the server, time zone will not be applied. If you return "2018-05-21 08:00Z", time zone will be applied. If you override TimeSpan to remove Z like 'YYYY-MM-DDTHH:mm:ss', timezone will be ignored no matter you pass it or not.

Pavlo Miklashevych
Sr. Frontend Developer


Post by pmiklashevich »

Please let me know if your problem is solved. If you need more help, please explain your problem better and provide a runnable testcase which shows your issue (or detailed instructions of how to reproduce with one of our samples). Cheers!

P.S. I'd like to understand you want UTC to be stored or you want a date-time to appear exactly the same regardless of timezone.

Pavlo Miklashevych
Sr. Frontend Developer


Post by zivo13 »

Greaaat! thanks a lot you are the best! its working good with that directions, regards

Post Reply