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

[Solved] RadScheduler DateTime string format

1 Answer 292 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Sentia
Top achievements
Rank 1
Sentia asked on 29 Oct 2007, 12:49 AM
Hi im using the client side edit for the scheduler top redirect to another page. This gives me a url like:

activity.aspx?start=1175232600000&allday=false

Just wondering how I can interpret the start datetime?  Do I need to new up a RadScheduler?

Thanks!

1 Answer, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 30 Oct 2007, 08:35 AM
Hi Sentia,

I guess that you are referring to the RadWindow integration example. The date here is represented as JavaScript ticks. You can use the following code to convert them to a date on the server:

private DateTime ParseJavaScriptTime(string jsTime) 
    Int64 tickDiff = new DateTime(1970, 1, 1).Ticks; 
    Int64 jsMilliseconds = Int64.Parse(jsTime); 
 
    DateTime time = new DateTime((jsMilliseconds * TimeSpan.TicksPerMillisecond) + tickDiff, DateTimeKind.Utc); 
    return time; 
 

This is not the best solution and since the initial version, we have improved the example to use a more readable date format. The new version is not uploaded yet, but you can use the following JavaScript code to format the date for use in the query string:

function formatDate(date) 
    var year = padNumber(date.getUTCFullYear(), 4); 
    var month = padNumber(date.getUTCMonth() + 1, 2); 
    var day = padNumber(date.getUTCDate(), 2); 
    var hour = padNumber(date.getUTCHours(), 2); 
    var minute = padNumber(date.getUTCMinutes(), 2); 
     
    return year + month + day + hour + minute; 
 
function padNumber(number, totalDigits)  
{  
    number = number.toString();  
    var padding = '';  
    if (totalDigits > number.length)  
    {  
        for (i = 0; i < (totalDigits - number.length); i++)  
        {  
            padding += '0';  
        }  
    } 
     
    return padding + number.toString();  
 

Then on the server-side you can parse it like this

private DateTime ParseJavaScriptTime(string jsTime) 
    DateTime result = DateTime.ParseExact(jsTime, "yyyyMMddHHmm"null, DateTimeStyles.AssumeUniversal); 
    return result.ToUniversalTime(); 
 

The example will update soon on the site and will be included in the upcoming Service Pack.

Greetings,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Scheduler
Asked by
Sentia
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Share this question
or