I'd like to create a TimeZoneInfo from it. How is this possible?
It's not possible. A time zone offset is not the same thing as a time zone. Please read the timezone tag wiki, especially the section titled "Time Zone != Offset".
... then how can I convert UTC dates on the server side into the client's timezone using the minutes offset?
Create a DateTimeOffset
that represents that moment in time. For example:
// From your database. Make sure you specify the UTC kind.
DateTime utc = new DateTime(2013, 1, 1, 0, 0, 0, DateTimeKind.Utc);
// From JavaScript
int offsetMinutes = 420;
// Don't forget to invert the sign here
TimeSpan offset = TimeSpan.FromMinutes(-offsetMinutes);
// The final result
DateTimeOffset dto = new DateTimeOffset(utc).ToOffset(offset);
Also, make sure you understand that the offset you retrieved from the client in JavaScript is not necessarily the correct offset to apply to your database date. When you get the offset, it has to be for a particular moment in time. Since many time zones change offsets for daylight saving time, you cannot assume that the offset you currently have is appropriate for any particular value in your database. Therefore, while the above code does what you asked, it is probably still not a good idea in general.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…