raddatepicker timezone issue

12 posts, 0 answers
  1. Bart Martin Ongtangco
    Bart Martin Ongtangco avatar
    6 posts
    Member since:
    Oct 2009

    Posted 15 Sep 2010 Link to this post

    hello,

    we're currently getting the selected date through the client object (javascript) and passing them through jQuery ajax.

    var theDate = $find('<%= radDatePicker1.ClientID %>').get_selectedDate();
    $.ajax({data: JSON.stringify({ dateIn : theDate })});

    [WebMethod()]
    public void GetDateSelected(DateTime? dateIn)
    {
        // do something
    }

    Our servers are currently in Arizona (GMT -7) and pacific time users doesn't experience the issue. If a client from a Mountain Timezone accesses the datepicker, the control increments 1 day to the selected date. Is there any way to prevent this?
  2. Tsvetina
    Admin
    Tsvetina avatar
    1876 posts

    Posted 15 Sep 2010 Link to this post

    Hello,

    If I understand you correctly, you can solve that by taking the current time of the user in javascript ( new Date().getTimezoneOffset() ) when a date is selected and if it belongs to a certain timezone, change the selected date to another one which is a day back.

    Best wishes,
    Tsvetina
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Bart Martin Ongtangco
    Bart Martin Ongtangco avatar
    6 posts
    Member since:
    Oct 2009

    Posted 15 Sep 2010 Link to this post

    i don't understand why i had to convert the date when they're simply selecting the date. why is it incrementing a day when the time difference is only 1 hour in between?
  5. Tsvetina
    Admin
    Tsvetina avatar
    1876 posts

    Posted 16 Sep 2010 Link to this post

    Hi,

    Could you please let me know does this happen in all cases or only for certain dates? If it happens occasionally could you give us exact dates which we can test? Also, if there are any specifics about the scenario where the dates are selected, please, let us know. 

    Additionally, could you confirm that the control which you use is RadDatePicker, not RadDateTimePicker?

    We will try to replicate the issue locally and if we manage we will track its cause.

    Sincerely yours,
    Tsvetina
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Bart Martin Ongtangco
    Bart Martin Ongtangco avatar
    6 posts
    Member since:
    Oct 2009

    Posted 16 Sep 2010 Link to this post

    it happens on all dates. i did mention RadDatePicker. thank you
  7. Tsvetina
    Admin
    Tsvetina avatar
    1876 posts

    Posted 22 Sep 2010 Link to this post

    Hi,

    Indeed, there is an issue with the selected dates of RadDatePicker but it is caused by current limitations of the javascript engine concerning daylight savings.

    However, there is a workaround for the issue. Its logic is to wire the DateSelected client-side event of the Calendar in the RadDatePicker, take the value of the selected date and then in the method handling DateSelected client-side event of the RadDatePicker itself compare if they are the same. If not, set the date selected in the calendar as a date of the RadDatePicker.

    You can find a sample project demonstrating that approach attached to this post.

    All the best,
    Tsvetina
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  8. Bart Martin Ongtangco
    Bart Martin Ongtangco avatar
    6 posts
    Member since:
    Oct 2009

    Posted 22 Sep 2010 Link to this post

    i'll check on this Tsvetina, I shall update you in a day after testing your solution. Thank you
  9. Bart Martin Ongtangco
    Bart Martin Ongtangco avatar
    6 posts
    Member since:
    Oct 2009

    Posted 22 Sep 2010 Link to this post

    i mimicked your example but still got the same issue. here's how i tested it.

    1) Server machine time (AZ GMT -7)
    2) Client machine time (EST GMT -5)
    3) I select the date
    4) selected date value passes through jQuery ajax then to webservice.

    once it gets in the webservice, the date just goes to the past with 1 day behind.
  10. Tsvetina
    Admin
    Tsvetina avatar
    1876 posts

    Posted 27 Sep 2010 Link to this post

    Hi Bart Martin Ongtangco,

    In this case the solution goes back to the initial idea - you should keep the datetime values in the datasource in UTC format and adjust them according to the client's timezone offset before you use them on the client-side. I am attaching a project which demonstrates such approach. The time is adjusted in the _buildTimeMatrix() method.

    Regards,
    Tsvetina
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Bart Martin Ongtangco
    Bart Martin Ongtangco avatar
    6 posts
    Member since:
    Oct 2009

    Posted 27 Sep 2010 Link to this post

    Sorry, but i am really getting disappointed with your suggestions, i feel that we're going in circles. am i supposed to convert everything to RadDateTImePicker? I did mention that i'm using RadDatePicker, but you keep on insisting I should instead use this.
  12. Tsvetina
    Admin
    Tsvetina avatar
    1876 posts

    Posted 30 Sep 2010 Link to this post

    Hello,

    You do not need to use a DateTimePicker, this javascript limitation influences the RadDatePicker in the same way, since its values are of DateTime type, even though it shows only the date. DateTimePicker is used in the sample in order to better visualize the scenario.

    The problem does not originate from our controls' implementation, as previously said, so the ways to work around it may unfortunately not be that intuitive.

    Sincerely yours,
    Tsvetina
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  13. Tom
    Tom avatar
    4 posts
    Member since:
    Aug 2011

    Posted 18 Apr 2012 Link to this post

    For reference, here is some code that could satisfy the needs of some users here. Tsvetina made a reference to it in a previous post.

    I use it for sending a date, via an AJAX call, that is interpreted on the server as a DateTime with a zeroed out time component:

                            var selDt = ipt.get_selectedDate();
                            var offset = selDt.getTimezoneOffset();
                            selDt.setMinutes(selDt.getMinutes() - offset)
                            var toDate = selDt;

    Some code I used came from a post here: http://stackoverflow.com/questions/1016847/converting-net-datetime-to-json/4372901#4372901
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017