it a little more complex. you have three time zones
- the sql server timezone. this is based on the hosts timezone setting, sql server always assumes stored dates are in its local timezone. GETUTCDATE() returns the local time offset to GMT time. if you store this in a datetime/datetime2 column, when retrieved it will assume its a local time. use datetimeoffset if you want the date and timezone stored together.
- the web server timezone. the web server code when its queries the data base assumes dates returned are in the web servers local timezone.
- the browsers (users) timezone.
in the .net framework dates are number of ticks from 1/1/0001. Dates are assumed to be local time. the runtime has methods to convert between timezones.
your code:
// get gmt timezone (not server time zone unless server is GMT)
TimeZoneInfo serverTimeZone = TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time");
// convert date assuming its GMT time to the web servers timezone
DateTime dateTime = TimeZoneInfo.ConvertTime(
time1, // some time
serverTimeZone, // treat as GMT time
TimeZoneInfo.Local); // Convert to local web server time
will only work if the dates are stored in the database in GMT or the web server is in the GMT timezone.
as suggested above, it more common to GMT on the database and webserver dates. then have the user specify their timezone, and convert the datetime to the user timezone.