Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
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 6-Dec-12 19:44pm
Edited 6-Dec-12 19:45pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

private static TimeZoneInfo INDIAN_ZONE = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
 
DateTime indianTime =  TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, INDIAN_ZONE);
  Permalink  
Comments
Milind_T at 7-Dec-12 5:42am
   
Please use "Improve Solution" to update your solution. Don't keep posting new solutions.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Simply apply culture in the ToString as shown below
 
DateTime.Now.ToString(CultureInfo.CreateSpecificCulture("hi-IN"))
 
That should do the trick
 
Hope that helps
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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).
  Permalink  
Comments
Member 9463303 at 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.
Krunal Rohit at 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)

  Print Answers RSS
0 OriginalGriff 7,105
1 DamithSL 5,079
2 Maciej Los 4,866
3 Sergey Alexandrovich Kryukov 4,617
4 Kornfeld Eliyahu Peter 4,384


Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 7 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100