I'm writing simple JavaScript. In that script I'm getting Event item Start date field value and End date field value from Custom calendar list. but the code retrieve different time

Example: here is the event from my Custom calendar List

enter image description here

when code retrieves Start time and End time fields value they are

Start Date: Fri Sep 30 2016 17:30:00 GMT+0530 (India Standard Time)

End Date: Fri Sep 30 2016 18:30:00 GMT+0530 (India Standard Time)

Please look at my code

    $(document).ready(function () {

      SP.SOD.executeFunc('sp.js', 'SP.ClientContext', getCalendarListItems);

     function getCalendarListItems() {
     var clientContext = new                                                        
    var myList = clientContext.get_web().get_lists().getByTitle('CustomCal');
    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml("<Where><IsNotNull><FieldRef Name='Title' /></IsNotNull></Where>");

    var items = myList.getItems(camlQuery);


        function () {

            var listItemInfo = '';
            var listItemEnumerator = items.getEnumerator();

            while (listItemEnumerator.moveNext()) {
                var oListItem = listItemEnumerator.get_current();

                    console.log("ID : "+ oListItem.get_id() );
                    console.log("Title : "+ oListItem.get_item('Title'));
                    console.log("StartDate: "+ oListItem.get_item('EventDate'));
                    console.log("EndDate: "+ oListItem.get_item('EndDate'));



2 Answers 2


Get the offset of server and convert local date to utc date.Using UTC date and offset you can get server date.

Following is code to get TimeZone and offset of server.

function getTimeZoneAndServerDateTime() {                   
            var context = SP.ClientContext.get_current();
            var web = context.get_web();
            var timeZone = web.get_regionalSettings().get_timeZone();
            function onSucceeded() {                     
                var info = timeZone.get_information();
                var offset = (info.get_bias() + info.get_daylightBias()) / 60.0;                 
             function OnError(){
                    console.error("Error Occured: " + args.get_message());

Time zone of SharePoint Online and your local system should be same. else you will get according to local system's time zone

With REST:


With JSOM:

var ctx = SP.ClientContext.get_current();
var timeZone = ctx.get_web().get_regionalSettings();
ctx.executeQueryAsync(function() {

Check this thread for more Getting the Timezone in Regional setting using javascript

  • Is there anything I can do in code. to fulfill my requirement Sep 29, 2016 at 8:14
  • match your local system timezone with office365 server's timezone and then check
    – Anil Pal
    Sep 29, 2016 at 8:15
  • how can I do that using code? Sep 29, 2016 at 8:50
  • using updated answer u can get server time zone
    – Anil Pal
    Sep 30, 2016 at 10:05
  • now convert it to your local time zone
    – Anil Pal
    Sep 30, 2016 at 10:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.