I need to return server time from a webservice. I’ve got the following code:
<WebMethod()> _
Public Function GetDate() As DateTime
Return DateTime.Now
End Function
The code always returns time based on timezone of the connected client (if I change the time zone, the webservice returns updated time, instead of local server time). How can I fix the issue?
The server actually sends the datetime in timezone of its local settings. The client probably interprets it differently (based on its local settings). Its safer to use UTC-times on the server or use DateTimeOffset to provide timezone information.