Dates and time zones
The server time zone cannot be changed - how to work with time zones in your application.
The time zone of a server is given by where it physically stands. Our EU servers are in Germany and use the Berlin time zone. This applies to web servers and database servers on both Free and Premium plans, and it cannot be changed for an individual website or database.
If your users are in another time zone, handle the conversion in your application.
Recommended approach
- Store dates and times in UTC. Use
DateTime.UtcNowin .NET andSYSUTCDATETIME()in SQL Server instead ofDateTime.NowandGETDATE(). - Convert to the user's time zone when displaying.
That way your data stays correct regardless of where the server is, and survives daylight saving time changes.
Converting in .NET
With the built-in TimeZoneInfo class:
var zone = TimeZoneInfo.FindSystemTimeZoneById("SE Asia Standard Time");
DateTime local = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, zone);
We recommend the Noda Time library, which makes working with time zones much safer:
// Current UTC time
var utcNow = SystemClock.Instance.GetCurrentInstant();
// Target time zone
var zone = DateTimeZoneProviders.Tzdb["Asia/Jakarta"];
// Convert UTC to the local time of that zone
var localTime = utcNow.InZone(zone);
Converting in SQL Server
Use AT TIME ZONE to convert a value in a query:
SELECT SYSUTCDATETIME() AT TIME ZONE 'UTC' AT TIME ZONE 'SE Asia Standard Time' AS LocalTime;
AT TIME ZONE is available in SQL Server 2016 and newer. It also converts the current time with its offset directly:
SELECT SYSDATETIMEOFFSET() AT TIME ZONE 'Central European Standard Time' AS CentralEuropeanTime;
Attach a time zone to a stored value
A DATETIME or DATETIME2 value carries no time zone information. The first AT TIME ZONE attaches one:
SELECT CAST('2024-11-28 12:00:00' AS DATETIME2) AT TIME ZONE 'UTC' AS TimeWithTimeZone;
Convert a column
SELECT EventTime AT TIME ZONE 'UTC' AS EventTimeUTC,
EventTime AT TIME ZONE 'Central European Standard Time' AS EventTimeCET
FROM Events;
Daylight saving time
AT TIME ZONE adjusts for daylight saving time automatically, according to the rules of the given zone — for example US rules for Pacific Standard Time and European rules for Central European Standard Time:
SELECT SYSDATETIMEOFFSET() AT TIME ZONE 'Pacific Standard Time' AS PSTTime,
SYSDATETIMEOFFSET() AT TIME ZONE 'Central European Standard Time' AS CETTime;
List the available time zones
SELECT * FROM sys.time_zone_info;