vishesh kumar
Top achievements
Rank 1
vishesh kumar
asked on 31 Jul 2011, 02:33 PM
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:
Regards,
Vishesh
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:
- Just access the link from any other time zone apart from the time zone of the server.
Regards,
Vishesh
9 Answers, 1 is accepted
0
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:
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
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.
0
Zach
Top achievements
Rank 1
answered on 20 Oct 2011, 09:56 PM
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.
"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.
0
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
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
0
Zach
Top achievements
Rank 1
answered on 25 Oct 2011, 04:22 PM
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?
0
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
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
0
Zach
Top achievements
Rank 1
answered on 28 Oct 2011, 03:36 PM
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?
0
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
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
0
F Beto
Top achievements
Rank 1
answered on 15 Nov 2012, 10:32 PM
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 & Time..."
Cursor="Hand" ToolTipService.ToolTip="Enter Date & 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.
In xaml file.
<telerik:RadDateTimePicker x:Name="rdpStartTime" Grid.Column="1" Grid.Row="2"
DateTimeWatermarkContent="Enter Date & Time..."
Cursor="Hand" ToolTipService.ToolTip="Enter Date & 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.
0
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
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.