Time picker bug: after databinding, time shows up in client time zone

10 posts, 0 answers
  1. vishesh kumar
    vishesh kumar avatar
    24 posts
    Member since:
    Sep 2009

    Posted 31 Jul 2011 Link to this post

    Hi,

    I want to use the custom data binding approach for the rad time picker as mentioned here:

    http://demos.telerik.com/aspnet-ajax/calendar/examples/datetimepicker/customcollection/defaultcs.aspx

    However, even in the demos ( I am accessing the site from INDIA), if I select some time say 9:30 am, it shows up on the time picker as 7pm. 7pm is the local time (IST) when I accessed this. 

    Ideally this should show up as 9:30 am only and the selected date of the time picker should be today's 9:30 am. 

    Please let me know how to proceed with it. 

    Steps to repro:
    1. Just access the link from any other time zone apart from the time zone of the server.

    Regards,
    Vishesh
  2. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 04 Aug 2011 Link to this post

    Hi Vishesh,

    Generally the RaDatedInput or RadTimePicker controls does not provide support for timezones. However, you can display the GMT (or other time zone) time by handling the OnDateSelected client-side event  and modifying the selected date with the appropriate offset using the Date.getTimezoneOffset() method. Here is a sample code snippet:
    <telerik:RadCodeBlock runat="server">
        <script type="text/javascript">
             var GMTset = false
                function DateSelected(sender, args) 
                
                    if (!GMTset) 
                    
                        GMTset = true
                        var offset = args.get_newDate().getTimezoneOffset(); 
                        var minutes = args.get_newDate().getMinutes();
                        args.get_newDate().setMinutes(offset); 
                        args.get_newDate().setMinutes(minutes);
                        sender.set_selectedDate(args.get_newDate()); 
                    
                    else 
                    
                        GMTset = false
                    
                
        </script>
    </telerik:RadCodeBlock>
    <telerik:RadTimePicker ID="RadTimePicker1" runat="server">
        <ClientEvents OnDateSelected="DateSelected" />
    </telerik:RadTimePicker>

    Also please check out the following forum thread which elaborate on the same matter:
    http://www.telerik.com/community/forums/aspnet-ajax/calendar/raddatepicker-timezone-issue.aspx

    I hope this helps.

    All the best,
    Radoslav
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Zach
    Zach avatar
    7 posts
    Member since:
    Jun 2004

    Posted 20 Oct 2011 Link to this post

    This is the most recent topic I can find on this issue (there are several) but I am experiencing exactly what the original poster is.  I don't believe you understand the problem, Radoslav.  Without making any modifications to your code, if I put the RadDateTimePicker on a page up on a server in any timezone different from mine, it adjusts the selected time by whatever my machine's offset is from the server.  As with the previous example, our server is in US Central Time, while my machine is Eastern time.  When I select 6:48 from the timepicker, the value that gets put into the textbox is 7:48.  Again, I have nothing special set up, this is the out of the box functionality.  This is a huge bug that appears to have been around since early 2009 (those were the earliest reportings of it that I can find).

    "Yavor" acknowledged this as a bug in the 2009 topic found here: http://www.telerik.com/community/forums/aspnet-ajax/calendar/radtimepicker-timezone-problem.aspx.
  5. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 25 Oct 2011 Link to this post

    Hello Geoff,

    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.

    Best wishes,
    Radoslav
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  6. Zach
    Zach avatar
    7 posts
    Member since:
    Jun 2004

    Posted 25 Oct 2011 Link to this post

    Why do I need to do that?  When they are selecting a time, it is completely independent of their time zone.  I want all users to see the same time set.  Why is this so complicated?
  7. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 28 Oct 2011 Link to this post

    Hello Geoff,

    In order to show the same time set you could use the RadTimePicker not bound to a custom collection. You could see the example on the following link:
    http://demos.telerik.com/aspnet-ajax/calendar/examples/datetimepicker/overview/defaultcs.aspx

    I hope this helps.

    Best wishes,
    Radoslav
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  8. Zach
    Zach avatar
    7 posts
    Member since:
    Jun 2004

    Posted 28 Oct 2011 Link to this post

    So the fix for a custom time list not working is to not use a custom time list?  Your dev's have supposedly been working on a real solution for this for 2 years now (once again, PLEASE READ http://www.telerik.com/community/forums/aspnet-ajax/calendar/radtimepicker-timezone-problem.aspx), so when can we expect that?
  9. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 02 Nov 2011 Link to this post

    Hello Zach,

    After the post in question our developers have made further research and it appeared that this is not a bug but rather a limitation. That is why we provided multiple workarounds.
    I hope that the solutions my colleague provided in this thread will help you achieve your goal.
    I will also update the other thread.

    All the best,
    Iana Tsolova
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  10. F Beto
    F Beto avatar
    11 posts
    Member since:
    Nov 2012

    Posted 15 Nov 2012 Link to this post

    I have this problem. How can I solve it?

    In xaml file.
    <telerik:RadDateTimePicker x:Name="rdpStartTime" Grid.Column="1" Grid.Row="2"
      DateTimeWatermarkContent="Enter Date &amp; Time..."
      Cursor="Hand" ToolTipService.ToolTip="Enter Date &amp; Time"
      SelectedValue="{Binding StartTime, Mode=TwoWay}"
      IsEnabled="{Binding IsEditable}" FontFamily="Arial"
      FontSize="13.333" Margin="9,0,0,9"/>



    Code Begind

    [Display(Name="Start Date & Time")]
            [NPSRequired]
            public DateTime? StartTime // made this nullable so we don't get a binding error when passed back from the UI
            {
                get { return dto.StartTime.ToLocalTime(); }
                set
                {
                    DateTime? dtTemp = value.HasValue ? value.Value : value;
                    SetValue("StartTime", dtTemp, () =>
                                                      {
                                                          if (dtTemp.HasValue)
                                                            dto.StartTime = dtTemp.Value;
                                                      });
                    IsChanged = true;
                }
            }

    And the problem is:

     The server is in UTC 0:00 and Bolivia is UTC: -4:00
    when I am choosing for example 6:00 PM (on time picker) it selects 2:00 PM. Why? 

     I put ToLocalTime(); because I need to show the date time in local time, but on the UI (RadDateTimePicker), the selection is wrong.

  11. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 19 Nov 2012 Link to this post

    Hi Franco,

    This forum thread elaborates on RadTimePicker for ASP.NET AJAX. However from the provided code snippet I saw that your question is for RadDateTimePicker from the Silverlight suite.  Could you please post your answer into the Silverlight radcontrols’ forum:
    http://www.telerik.com/community/forums/silverlight.aspx
    Additionally at a meantime you could check out the following forum threads:
    http://www.telerik.com/community/forums/silverlight/timepicker/timepicker-defaults-to-am.aspx

    I hope this helps.

    Kind regards,
    Radoslav
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017