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.


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

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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