0

I am running a C# application in which I get the current date and time using DateTime.

DateTime currentTime = DateTime.Now;

When I run this code on my local machine, it returns the UTC +05:30 (local time). However, when I deploy this as a solution on the server, it returns some other time -> 11:50 AM something.

How do I set the value of current time so that it reflects time from one timezone. More specifically the Indian time zone.

Spider Man
  • 415
  • 4
  • 10
  • 26
  • use `DateTime.UtcNow` – NtFreX Nov 27 '16 at 12:35
  • 1
    You can convert the DateTime object into whatever time zone you want. But seriously, you shouldn't be dealing with time zones except for date/times that will be displayed to a user, and in that case, you want it to be the user's local time zone. Otherwise, always use UTC time, obtainable with `DateTime.UtcNow`. – Cody Gray - on strike Nov 27 '16 at 12:36
  • Thanks a lot. @CodyGray I am using DateTime.UtcNow – Spider Man Nov 27 '16 at 12:37

0 Answers0