We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Dates from PHP

Im passing in data for events in ejSchedule from a PHP backend web service and it doesn't seem to like the way Im passing in the start and end dates. In all your examples your handing it a javascript Date object so I am not sure how to hand them in through php. 

I have tried a date string, a epoch time number, and some other ways and nothing seems to work. How should I hand the dates in through the JSON made in php


7 Replies

UM Uma Maheswari C Syncfusion Team July 8, 2016 07:25 PM UTC

Hi David, 
Thank you for contacting Syncfusion support. 
We have prepared the Scheduler sample depicting the way to connect it with PHP backend service and also the date conversion that needs to be handled for the StartTime and endTime fields at the client-side which are returned as JSON from the server, before it is being assigned to the Scheduler dataSource. This date conversion needs to be carried out within the Create event of the Scheduler. Please refer the runnable sample from the below downloadable location –  
Please create the required database and the tables with required fields. Here, we have used the database named demo. 
Note: The downloaded files needs to be loaded into the server before running it. 
Kindly refer the sample and let us know if you require any further assistance on this. 
C. Uma Maheswari 

DB David Barrett July 10, 2016 02:36 AM UTC

 Thank you very much that helped me figure out the dates thing. One thing though is this way passes no information as to where they are in the calendar (load on demand) so that I don't have to pass all the schedule information which is upwards of 30000 records to date and just growing, and with 60-70 resources I am not able to load all data at once as the page will crash or be so slow its unusable. 

Is there a change I can make to the ej.Query call that will allow me to piecemeal records quickly? Or do I need to put a different function in the change of view call as well as the create function?


MP Mahesh Palanisamy Syncfusion Team July 11, 2016 04:55 PM UTC

Hi David,    
Thanks for the update. 
By default, Scheduler supports Load data on demand concept. Kindly refer to the following links to know more about the concept and hot it works from here -   
For other data manager querying (ej.Query()) options, kindly refer here - http://help.syncfusion.com/js/datamanager/query     
Kindly check the above link and let us know, if you need any further assistance on this. 

DB David Barrett July 11, 2016 05:38 PM UTC

Thanks for the reply,

    I understand how the load on demand feature works when using your direct connectors, my question was more based on the answer you gave me above to get my php information into the calendar. With the method above, the "create" function call that goes and gets the schedule information, hands the back-end no data to tell me what data to load-on-demand, since I am not using the standard connectors. The standard connectors hand the back-end the current date, the view, and other things. The function you showed me hands an empty call with no request data. I was wondering how I use that function you sent me with the features that allow for load-on demand. 

Also I am using plain straight javascript (jquery) and php/mysql (no angular, azure, oData connectors or anything/systems like this)


MP Mahesh Palanisamy Syncfusion Team July 19, 2016 03:49 PM UTC

Hi David, 

Thanks for your patience. 

We have prepared the workaround sample to meet  your requirement with load on demand concept along with the option to handle the back-end data [current date, current view and other things] which can be downloaded from the below location: 
In client-side, we have raised the “create” and “actionComplete” event to get the required data from database and also to process the date conversion problem. In these events, we can also pass additional parameters to the server-side. 

The following code has been used in the above sample - 

     function getData(args) { 
        if (args.type == "create" || args.type == "actionComplete") { 
            var dataManger = ej.DataManager({ url: "Data.php" }); 
            dataManger.adaptor = new ej.UrlAdaptor(); 
            var query = new ej.Query(); 
            //Here pass the required parameters to filter data 
            query.addParams("CurrentDate", new Date(new Date(this.currentDate()).setHours(0, 0, 0))).addParams("CurrentView", this.currentView()).addParams("CurrentAction", args.type); 
            var queryPromise = dataManger.executeQuery(query); 
            queryPromise.done(function (e) { 
                var appointments = [], data = e.result; 
                for (var i = 0; i < data.length; i++) { 
                    appointments.push({ Id: parseInt(data[i]["Id"]), Subject: data[i]["Subject"], AllDay: parseInt(data[i]["AllDay"]), StartTime: new Date(data[i]["StartTime"]), EndTime: new Date(data[i]["EndTime"]), Recurrence: parseInt(data[i]["Recurrence"]), RecurrenceRule: data[i]["RecurrenceRule"] }); 
                $("#Schedule1").ejSchedule({ appointmentSettings: { dataSource: appointments } }); 

Kindly check the above sample and let us know, if you need any further assistance on this. 


DB David Barrett July 19, 2016 04:29 PM UTC

Thanks for the reply, that gives me all the information I need. Thanks!

KK Karthigeyan Krishnamurthi Syncfusion Team July 20, 2016 06:28 AM UTC

Hi David,   
We are happy to hear that our previous solution worked as per your requirement. Kindly, let us know if you need any further assistance.   

Live Chat Icon For mobile
Up arrow icon