Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am trying to build a calendar with date time columns. My SP 2007 server is in US and I am trying to use this site in India. My server returns the EventDate column value in India format. I want to convert it in US date.

For example:


My Event Date I set is: 5/29/2012 3:00 PM
I want to convert it in: 5/29/2012 2:30 AM (US Time)

Any help will be appreciated.

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

To convert a datetime to an other timezone in c# you can use this:

TimeZoneInfo timeZoneInfo; 

DateTime dateTime ; 

//Set the time zone information to US Mountain Standard Time 

timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("US Mountain Standard Time"); 

//Get date and time in US Mountain Standard Time 

dateTime = TimeZoneInfo.ConvertTime(DateTime.Now, timeZoneInfo);

//Print out the date and time

Console.WriteLine(dateTime.ToString("yyyy-MM-dd HH-mm-ss")); 

A List of TimeZones and further documentation you can find here:

And in the MSDN: http://msdn.microsoft.com/en-us/library/system.timezoneinfo.getsystemtimezones.aspx

Conversion with XSLT: http://www.xsltfunctions.com/xsl/fn_adjust-datetime-to-timezone.html

share|improve this answer
    
I am trying to convert timezones in XSLT in SharePoint Designer. –  Ashish May 29 '12 at 8:12
    
I am getting a way I think. However i am unable to use function adjust-dateTime-to-timezone(). It gives me error: adjust-dateTime-to-timezone is not a valid XSLT or XPath function. Am I missing a xmlnamespace? An example would be helpful. Thanks. –  Ashish May 29 '12 at 9:36
    
@Ashish I think it is is a XPath 2.0 function, looks as if you called it from a 1.0 processor. –  MOI May 29 '12 at 10:22
    
I changed the version of my xsl:stylesheet declaration to version="2.0". How can i check if I can process 2.0 functions as well? –  Ashish May 29 '12 at 10:24
    
@Ashish try one of these functions: saxon.sourceforge.net/saxon7.4/functions.html –  MOI May 29 '12 at 10:28
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.