Click here to Skip to main content
12,815,019 members (39,895 online)
Rate this:
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
Updated 6-Dec-12 19:45pm
Rate this: bad
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);
Milind_T 7-Dec-12 5:42am
Please use "Improve Solution" to update your solution. Don't keep posting new solutions.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Simply apply culture in the ToString as shown below


That should do the trick

Hope that helps
Rate this: bad
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).
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.
Krunal Rohit 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170308.1 | Last Updated 7 Dec 2012
Copyright © CodeProject, 1999-2017
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