Reputation: 908
When using ToLocalTime(), how is local time determined? Is local time from the server or the client? My assumption would be the server running the application.
Upvotes: 31
Views: 22208
Reputation: 241563
It is the local time zone of the computer that code is running on. In an ASP.Net application, the code runs on the server - so that's the time zone that it will return.
The behavior of this function is actually dependent on the .Kind
property of the source value. From the MSDN link you gave:
DateTime
is converted to local time.DateTime
is assumed to be a UTC time, and the conversion is performed as if Kind were Utc.This is non-obvious behavior. You can read other related problems with the .net DateTime
class here and here.
A few other points:
Upvotes: 43
Reputation: 5318
ToLocalTime()
, in this case, executes on the server. Therefore the time is evaluated on the server, and it'll return the server time to the client.
Upvotes: 10
Reputation: 28839
Local here is the timezone of the machine that the function executes on.
Upvotes: 2