Ever faced a problem where you capture the date-time and find that it turned out to be server’s local time. This is a common thing with servers spread across the world and being accessed from anywhere. If we need time specific to a zone, here’s a small code snippet…
* This function returns the Indian Standard Time (GMT +0530). You can change the CaseOffset variable as per your need.
(Applies to VB.NET)
''' <summary>
''' Function to return the Current Indian Standard Time (GMT +0530)
''' </summary>
''' <returns>Current IST</returns>
''' <remarks>VSR</remarks>
Public Shared Function getDate() As DateTimeDim IST As DateTime
Dim CaseOffset As TimeSpan = New TimeSpan(5, 30, 0)
IST = DateTime.UtcNow.Add(CaseOffset)
Return ISTEnd Function

0 comments:
Post a Comment