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

[Solved] eventArgs.get_startTime() doesn't give me the correct time

9 Answers 147 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Jonathan asked on 09 Jun 2008, 03:21 PM
When I am trying to get the start time of an appointment insert using 

eventArgs.get_startTime()

I get a time which is 4hrs ahead of my time. How can I change this? My TimeZoneOffset is set to 00:00:00 and the culture is set to UK.

If I alter the TimeZoneOffset this breaks my appointments as they start being displayed at the wrong times.
Thanks
Jon

9 Answers, 1 is accepted

Sort by
0
Jonathan
Top achievements
Rank 1
answered on 10 Jun 2008, 02:56 PM
Does nayone know anything about this?
0
Yamil
Top achievements
Rank 1
answered on 11 Jun 2008, 04:24 PM
This is a known issue. I f you try  the sample  'External Edit with a RadWindow" (http://www.telerik.com/DEMOS/ASPNET/Prometheus/Scheduler/Examples/RadWindow/DefaultCS.aspx) and click to create a new appoint, for example at 8:00 am you got in the Edit window 12 :00 m.
I think the problem is with teh javascript function formatDate in the line var hour = padNumber(date.getUTCHours(), 2);

Any fix for this problem ?
0
Jonathan
Top achievements
Rank 1
answered on 12 Jun 2008, 07:17 AM
I wonder when they will have a fix for this then because it's a bit annoying.

Do you have a work around?
0
Dimitar Milushev
Telerik team
answered on 12 Jun 2008, 07:24 AM
Hello Jonathan,

This will be fixed in the upcoming Service Pack 2 that should be released by the end of next week.

Please excuse us for the inconvenience.

Greetings,
Dimitar Milushev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jonathan
Top achievements
Rank 1
answered on 12 Jun 2008, 07:25 AM
Excellent, I'll wait till next week.
0
Accepted
Yamil
Top achievements
Rank 1
answered on 12 Jun 2008, 12:52 PM
I rewrote the formatDate function as below and it is working ok :

function formatDate(date) 
   var temp = date.toGMTString() ;    // convert date to a GMT string; 
   date = new Date(temp);    // convert string to a Date object 
             
   var year = padNumber(date.getUTCFullYear(), 4); 
   var month = padNumber(date.getUTCMonth() + 1, 2); 
   var day = padNumber(date.getUTCDate(), 2); 
   var hour = padNumber(date.getUTCHours()-4, 2); 
   var minute = padNumber(date.getUTCMinutes(), 2); 
   return year + month + day + hour + minute; 
 
       
0
Jonathan
Top achievements
Rank 1
answered on 12 Jun 2008, 01:30 PM
Hi Yammil

Thanks for that, it works exactly how I wanted, although I had to change the hours for the UK.

Thanks a lot
Jon
0
Accepted
T. Tsonev
Telerik team
answered on 12 Jun 2008, 04:49 PM
Hi,

Sorry for the confusion, but the problems you are experiencing are in fact a result of a fix that we have implemented. Beginning with SP1 you no longer need to call getUTCxxx, instead the value returned from the functions is accurate, regardless of the current time zone of the user. The correct implementation of formatDate now looks like this:

function formatDate(date) 
    var year = padNumber(date.getFullYear(), 4); 
    var month = padNumber(date.getMonth() + 1, 2); 
    var day = padNumber(date.getDate(), 2); 
    var hour = padNumber(date.getHours(), 2); 
    var minute = padNumber(date.getMinutes(), 2); 
     
    return year + month + day + hour + minute; 

We will take care to fix the online example too.

All the best,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Yamil
Top achievements
Rank 1
answered on 12 Jun 2008, 05:36 PM
I will change the code
Thanks Tsvetomir
Tags
Scheduler
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Jonathan
Top achievements
Rank 1
Yamil
Top achievements
Rank 1
Dimitar Milushev
Telerik team
T. Tsonev
Telerik team
Share this question
or