Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting default Time Zone for DateTimes

I have an C# application that will be running in a different timezone than where I am developing it. It uses time-based data, and performs calculations and makes decisions based on the time-based data. I want to test using the real data, so was wondering how I could set the time zone or something similar of the application as if I was in the other timezone, and all variables of type DateTime would use this default time?

like image 939
theringostarrs Avatar asked Feb 21 '11 21:02

theringostarrs


1 Answers

The easiest way would be to just change the timezone on your machine, which is getting picked up by the DateTime class. As a general recommendation I would do all time related calculations and storing of times in UTC, only for display purposes convert to the local time zone.

like image 186
BrokenGlass Avatar answered Oct 03 '22 14:10

BrokenGlass