This is a migrated thread and some comments may be shown as answers.

Setting timezone for RadCalendar

5 Answers 141 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 14 Oct 2008, 05:27 AM
Hi

I'm not sure if this post belongs here in RadCalendar or for RadDateInput.

Basically I have some RadDateInputs that share a common RadCalendar.

I know how to highlight Today's date in the RadCalendar, but is that date based on the browser's timezone?

What I need to do is programatically set the timezone from our database (like I do with culture). That way the UTC offset would be correct.

How would I go about doing this?


Kind regards

Mark Eaton

5 Answers, 1 is accepted

Sort by
0
Missing User
answered on 14 Oct 2008, 07:22 AM
Hello Mark,


To see more information on the requested functionality, please refer to the following help article:

http://www.telerik.com/help/aspnet-ajax/calendar_localizationcultureinfo.html

Kind regards,
Plamen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mark
Top achievements
Rank 1
answered on 14 Oct 2008, 10:21 PM
Hi Plamen

I could see the examples for culture but not for timezones.

I may have missed it but could you please provide a programming example.

Basically if we have a user whose laptop's timezone is set for London Timezone but would rather have our website show dates in Australian Eastern Standard Time timezone I would like to be able to set this programmatically.

Otherwise during certain hours of the day it would look 1 day out.


Kind regards

Mark Eaton
0
Missing User
answered on 17 Oct 2008, 10:54 AM
Hi Mark,


Generally the RaDatedInput or RadCalendar 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:

        <div> 
            <script type="text/javascript">  
            var GMTset = false;  
            function DateSelected(sender, args)  
            {  
                if (!GMTset)  
                {  
                    GMTset = true;  
                    var offset = args.get_newDate().getTimezoneOffset();  
                    args.get_newDate().setMinutes(offset);  
                    sender.set_selectedDate(args.get_newDate());  
                }  
                else  
                {  
                    GMTset = false;  
                }  
            }  
            </script>  
               
            <telerik:RadDateTimePicker ID="RadDateTimePicker1" runat="server" Width="200px">  
                <DateInput DateFormat="R"></DateInput>  
                <ClientEvents OnDateSelected="DateSelected" />  
            </telerik:RadDateTimePicker>          
        </div> 



Regards,
Plamen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mark
Top achievements
Rank 1
answered on 19 Oct 2008, 11:33 PM
Actually I didn't want to do it for the selected date but for "Today's Date".

In the aspx page my RadCalendar that is shared is defined as:

<telerik:RadCalendar ID="calVenue" runat="server">
    <SpecialDays>
        <telerik:RadCalendarDay Repeatable="Today" Date="">
            <ItemStyle CssClass="YellowGreen" />
        </telerik:RadCalendarDay>
    </SpecialDays>
</telerik:RadCalendar>


Can I set this programatically on the web server to a particular timezone?

Or would I need to programatically do this in Javascript?



Kind regards

Mark Eaton
0
Mark
Top achievements
Rank 1
answered on 19 Oct 2008, 11:54 PM
I found a way to achieve this.

In the aspx page I now set the RadCalendar Repeatable property to "None" instead of "Today".

Then on the web server I set the date that I want (which is a calculation based on the user's preferred timezone).

Works nicely.


Kind regards

Mark Eaton
Tags
Calendar
Asked by
Mark
Top achievements
Rank 1
Answers by
Missing User
Mark
Top achievements
Rank 1
Share this question
or