Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
In my project i am using DateTime.Now function to get current date.But the server is in UK so i get date in US Server Date.Have any code to set Indian standard time to Global.asax , and get Indian time to all pages when call datetime.now function?
Posted
Updated 11-Mar-18 21:05pm
Comments
Suvendu Shekhar Giri 1-Oct-16 14:33pm    
accept a solution or let us know if u still need help. accepting a solution will help removing the question from Unanswered list.

private static TimeZoneInfo INDIAN_ZONE = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
DateTime indianTime =  TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, INDIAN_ZONE);
 
Share this answer
 
Comments
Member 12862681 23-Nov-17 5:13am    
how to insert datetime with am or pm.?
See this : DateTime.UtcNow Property[^] and understand how it works. Go through the example mentioned there. Let me know if there is any difficulty.
 
Share this answer
 
Try This...

public DateTime IndianStandard(DateTime currentDate)
{
TimeZoneInfo mountain = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
DateTime utc = currentDate;
return TimeZoneInfo.ConvertTimeFromUtc(utc, mountain);
}
 
Share this answer
 
this will work
System.DateTime.UtcNow.AddHours(5.5).ToString()
or
System.DateTime.UtcNow.AddHours(5.5).ToString("dd/MM/yyyy HH:mm:ss tt")
 
Share this answer
 
you can try this solution :-

System.DateTime.UtcNow.AddMinutes(330);

else

DateTime.UtcNow.AddMinutes(330).Ticks.ToString();
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900