Lightbox is adding 2 hours to time when retrieving data

Hello,

when I check an event in my lightbox and calendar it has 2 hours added to both the start time and end time. The time saved in the database is correct but the time in the lightbox and calendar is not.

For example, if it says it’s saved as 6pm on the database it comes out as 8pm or 20:00 when displayed in the lightbox and calendar.

Here is a partial of my calendar/lightbox code:

[code]

        function init() {                
            // original
            // *****************************************************************************************
            scheduler.init("scheduler_here", new Date(), "month");
            //scheduler.load("/Home/Data","json");
            scheduler.load("/Calendar/Data2", "json");
     
            // set the label for the year tab
            scheduler.locale.labels.year_tab = "Year";

            // allow editing of event
            scheduler.config.details_on_create = true;
            scheduler.config.details_on_dblclick = true; 
            
            // readonly mode off
            scheduler.config.readonly_form = false;

            // change from military time to standard time in the lightbox - %h is hour based on 12hr clock, %i is minutes with a leading 0, %A displays the AM and PM
            //scheduler.templates.time_picker = scheduler.date.date_to_str("%h:%i %A");

            // change the time intervals in the lightbox to 30 minutes rather than the default of 5
            scheduler.config.time_step = 30;


            // create a mini calendar
            function show_minical() {
                if (scheduler.isCalendarVisible())
                    scheduler.destroyCalendar();
                else
                    scheduler.renderCalendar({
                        position: "dhx_minical_icon",
                        date: scheduler._date,
                        navigation: true,
                        handler: function (date, calendar) {
                            scheduler.setCurrentView(date);
                            scheduler.destroyCalendar()
                        }
                    });
            }[/code]

I think it might be on my providers end since when I test it locally at home it seems to work fine. Is there anything I can do or get my provider to check to see if it’s on their end?

Thanks,
Alfredo

Hi Alfredo,

The code you provided isn’t displayed how you add 2 hours to start and end dates.
We need to reproduce the issue to have the opportunity to understand the cause of it. It will be nice if you can provide with access to your application or replicate the issue here docs.dhtmlx.com/scheduler/snippet/d5635e35

Hi Polina,

thanks for your reply. I think I figured out why it’s happening, now I have to figure out how to fix it. The server is in pacific standard time and I am in central standard time. So that is why 2 hours are being added when I retrieve the data from the sever (it’s stored correctly as CST date in the server). Here is my C# code that retrieves the data:

[code] var serializer = new JavaScriptSerializer();
var serializedResult = serializer.Serialize(db.Event.ToList().Where(ev => ev.status == “Active”));

            // fix the dates before returning them     
            serializedResult = Regex.Replace(serializedResult, @"\""\\/Date\((-?\d+)\)\\/\""", "$1");


            return serializedResult;[/code]

So I have to figure out how to get the date to display in CST. Is there a way to covert the date back to CST (i.e. minus the 2 hours)? Or should I focus on trying to get my code to convert it?

Thanks!
Alfredo

Hello,

I’ve been playing around with this and I’m a bit closer now. I have my dates returned from the server in this format:
2017-06-17T22:30:00

And I’ve defined my dates in my calendar as having this format:
scheduler.config.xml_date = “%Y-%m-%dT%H:%i:%s”;

But that xml_date format doesn’t work. If I take out the time portion (i.e. T%H:%i%s) it works but then my events don’t have time attached to them. Is there something I’m missing when I’m defining my date/time format in the calendar?

Thanks!
Alfredo

Hello,

To specify date format by xml config you can use only characters from the list: docs.dhtmlx.com/scheduler/settings_format.html

So, you need to remove ‘T’ from date to the next: “2017-06-17 22:30:00”. After this events should start rendered on the page.