0

I am writing an winforms application that is supposed to be used by users from multiple timezones on the same data files.
Part of the operations use timestamps and obviously I want those to be of the same time globally, say ZULU-time (GMT+0 without DST). For now it can be a hard-coded solution.
This seems like something to set globally, in the initialization of the application,
but I do not know where exactly to set this.

This question seems to be more about display of data, which is irrelevant here. I actually want everyone to see the same DateTimes round the globe.

Community
  • 1
  • 1
Mark
  • 419
  • 1
  • 6
  • 21
  • Use UTC https://msdn.microsoft.com/en-us/library/system.datetime.touniversaltime(v=vs.110).aspx –  Jul 06 '16 at 22:54
  • @x... that generally does what I need. but I'd like to not have to think about this everytime I use "DateTime.Now" or similar. Is there no way to globally force this? – Mark Jul 06 '16 at 23:05
  • The UTC version of DateTime.Now is DateTime.UtcNow. "Now" is local time. –  Jul 06 '16 at 23:07
  • @x... so all I have to do, is use DateTimeUTC in place of DateTime on all occasions? Sound good! – Mark Jul 06 '16 at 23:11
  • Yes, and all over the world have always the same time, example: if you are in London, UTC is 10am. If you are in US, UTC is also 10am, if you are in Japan, UTC is also 10am. –  Jul 06 '16 at 23:15

1 Answers1

1

Use:

DateTime.UtcNow

or

DateTime.ToUniversalTime()

later, if you want to local time, you can convert it to local time.
https://msdn.microsoft.com/en-us/library/system.datetime.utcnow(v=vs.110).aspx https://msdn.microsoft.com/en-us/library/system.datetime.touniversaltime(v=vs.110).aspx