Skip to content

Infragistics Community Forum / Web / Ignite UI for jQuery / IgDatePicker – selecting value from datepicker in javascript outputs the datetime in browser timezone

IgDatePicker – selecting value from datepicker in javascript outputs the datetime in browser timezone

New Discussion
Shwetha onkarappa
Shwetha onkarappa asked on Dec 17, 2019 1:50 PM

Hi,

generated code for Igdatepicker is below

<div class="ui-igeditor-input-container ui-corner-all"><input type="text" class="ui-igedit-input hasDatepicker" id="DatesScheduledShipDateValueEditingInput" role="combobox" aria-label="Date Picker" style='height: 100%; text-align: left;'><input type='hidden' name='DatesScheduledShipDateValue' value='2015-09-07T18:30:00.000Z' data-rule-required='true' data-msg-required='Value must be specified.' data-valtype='igDatePicker'></div>

if i try to get the value in javascript gives me below value

$("#DatesScheduledShipDateValue").igDatePicker('value')
Tue Sep 08 2015 00:00:00 GMT+0530 (India Standard Time)

but i need the value in UTC.. how can i select this(the value which is associated with the generated HTMl is value="2015-09-07T18:30:00.000Z")

pcan anyone help me on this

Thanks,

Shwetha

Sign In to post a reply

Replies

  • 0
    Nikolay Alipiev
    Nikolay Alipiev answered on Dec 20, 2017 12:36 PM

    Hi, Shwetha.

    I hope that I will be able to help you with my answer.

    If you set the option displayTimeOffset to 0 then display value will be UTC, no matter what is browser time:

    $("#dateEditor").igDateEditor({
       value: "2015-09-07T18:30:00.000Z",
       dateInputFormat: "dateTime",
       displayTimeOffset: 0
      });

    As far as about the value method, we have designed the date editor to return always the value the browser is using – the one that it is automatically reverted. So you it is normal to see it that way. In order to get the UTC time just use the JavaScript methods to get UTC date – like for the hours – getUTCHours.

    var browserDate = $("#DatesScheduledShipDateValue").igDatePicker('value');

    var UTCHours = browserDate.getUTCHours().

    If you have further questions, don't hesitate to ask!

    Best regards,

    Nikolay Alipiev

    Software Developer

    • 0
      Sharmila Naik
      Sharmila Naik answered on Dec 17, 2019 1:50 PM

      Hi Nikolay,

      I have one question related to similar topic. I am using igdatepicker for date control.

      I want to set different timezone for the selected date. (other than local timezone.)

      For instance, local browser's timezone is IST (i.e. GMT+5:30) . But I want to set date with Germany timezone ( GMT+1)

      Is this feasible with infragestic IgDatePicker? If so, what options do I have to set?

      Your inputs would be really helpful.

      Thanks,

      Sharmila

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Shwetha onkarappa
Favorites
0
Replies
2
Created On
Dec 17, 2019
Last Post
6 years, 10 months ago

Suggested Discussions

Tags

No tags

Created by

Created on

Dec 17, 2019 1:50 PM

Last activity on

Dec 17, 2019 1:50 PM