We are saving all dates in UTC in our database and also saving offset for each user.
We are converting to localtime by following function:
Private Function ConvertToLocalDateTime(ByVal utcOffset As Integer?, ByVal DateToConvert As DateTime?) As DateTime?
getdatetime = DateToConvert.Value.AddHours(utcOffset)
If getdatetime.IsDaylightSavingTime Then
getdatetime.AddHours(-1)
End If
Return getdatetime
End Function
But still dates are 1 or 2 hours off.
How can we convert correctly to localtime from utcoffset also taking care of daylight saving?