Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Label2.Text = DateTime.Now.ToString();

i am using this code to get server time
now i want indian time.. without using client pc time..
i want direct by code..
Posted
Updated 6-Dec-12 18:45pm
v2

private static TimeZoneInfo INDIAN_ZONE = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");

DateTime indianTime =  TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, INDIAN_ZONE);
 
Share this answer
 
Comments
MT_ 7-Dec-12 5:42am    
Please use "Improve Solution" to update your solution. Don't keep posting new solutions.
Simply apply culture in the ToString as shown below

C#
DateTime.Now.ToString(CultureInfo.CreateSpecificCulture("hi-IN"))


That should do the trick

Hope that helps
 
Share this answer
 
C#
Label2.Text = DateTime.UtcNow.ToString();

DateTime.UtcNow Property gets a DateTime object that is set to the current date and time on this computer, expressed as the Coordinated Universal Time (UTC).
 
Share this answer
 
Comments
Member 9463303 7-Dec-12 0:57am    
No, actually i don't want to get current local PC time. i want Indian new delhi time which comes from server or directly by code. please help me.
[no name] 7-Dec-12 1:02am    
Please explore the link.. :)

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