Setting timezone for RadCalendar

6 posts, 0 answers
  1. Mark
    Mark avatar
    97 posts
    Member since:
    Nov 2007

    Posted 14 Oct 2008 Link to this post

    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
  2. Plamen Peshev
    Admin
    Plamen Peshev avatar
    885 posts

    Posted 14 Oct 2008 Link to this post

    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.
  3. Mark
    Mark avatar
    97 posts
    Member since:
    Nov 2007

    Posted 14 Oct 2008 Link to this post

    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
  4. Plamen Peshev
    Admin
    Plamen Peshev avatar
    885 posts

    Posted 17 Oct 2008 Link to this post

    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.
  5. Mark
    Mark avatar
    97 posts
    Member since:
    Nov 2007

    Posted 19 Oct 2008 Link to this post

    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
  6. Mark
    Mark avatar
    97 posts
    Member since:
    Nov 2007

    Posted 19 Oct 2008 Link to this post

    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
Back to Top