I would recommend to always use UTC (GMT) time on the server side (in code-behind, database, etc), and convert time from UTC to local time for display purposes only. This means that all time manipulations - including saving time in database, performing calculations, etc - should be be done using UTC.
The problem is: how does your code-behind know what is the time zone of the client browser? Say the user enters some date/time value (such as 12/30/2009 14:30) in the form and submits it to the server. Assuming that the user submitted local time, how does the server know how to convert this value to UTC?
The application can ask the user to specify the time zone (and save it in a persistent cookie or database), but it requires and extra effort from the user, and your app would need to implement the logic and screens for this. It would be nicer if the app could determine client's time zone automatically.
This may sound a bit complicated, and it is, but after I wrote helper functions, integrating this feature in the site was a matter of making a single call in Page_Load (of pages that needed time conversion), and using time conversion routines when sending and retrieving time values to and from the browser. Here is an example of how it can be used:
// Derive the form class from BaseForm instead of Page.
public class WebForm1: BaseForm
private void Page_Load(object sender, System.EventArgs e)
// If we only want to load the page to generate the time
// zone offset cookie, we do not need to do anything else.
// Assume that txtStartDate is a TextBox control.
// To display a date-time value, convert it from GMT (UTC)
// to local time.
DateTime startDate = GetStartDateFromDB(...);
txtStartDate.Text = FormatLocalDate(startDate);
// To save a date-time value, convert it from local
// time to GMT (UTC).
DateTime tempDate = DateTime.Parse(txtStartDate.Text);
DateTime startDate = ConvertLocalTimeToUtc(tempDate);
If you need more specifics, check out the Its About Time: Localizing Time in ASP.NET Applications article (sorry, but I do not have a direct link to the article on the publisher's site, since asp.netPRO restricts access to paid subscribers only; there are links to PDF copies, though). I wish I could post the sample from the article, but I don't want to violate the copyright; however, here is a project to build a helper library that has all necessary functionality and documentation (just ignore the stuff you do not need).
UPDATE: The article has been posted online with sample project by the new publisher here.
I disagree with the statement that your app should determine user's timezone automatically. Users can set any timezone/date/time they want in theirs operating system and bypass your business rules. Never trust user input.
I don't understand your point Bruno. First, there are no business rules associated with time zones. It's an issue of usability. We could've used GMT, but it's not convenient for users, so we use local time. If user changes the system clock (or whatever way they use to specify time zone), who cares? I don't see a problem here. I'm also not following a transition from your first statement to the second statement. Do you not like the "automatic" part, or do you not like the idea of using local time at all (if it's not done automatically, user must be able to change it somehow, right)?
+1. @BrunoSalvino, how would you suggest to pass the timezone data? The other way I can think of doing this is providing an explicit user input. The latter is even less trustworthy than the automatic solution proposed here, as the user is more likely to make mistake. From user's perspective this will require timezone inputs, which is not user-friendly especially when the page does not even require a date-time information, but still has to persist the date and time of certain user interaction (like the time the user uploaded some file or did a financial transaction).