0

I want to switch system date between config date from table in DB and current date.

This is my step.

  1. I store configuration datetime to table in database
  2. I have add appsetting "UseCurrentDate" with value "True" or "False" in web.config
  3. In application start I read appsetting value from web.config and try to switch between 2 system date
  4. I try to change date with my config from database with this solution. (Change system date programmatically)

  5. How can I switch to current date if I set appsetting value to change system date to current date?

  6. Is it a good solution to do this?
Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Witchayanin
  • 57
  • 2
  • 8
  • 2
    6: No, it is **never** a good solution changing the system date, instead adjust the software to use a particular date as a parameter instead of using the system date. The rest of your questions are moot, you shouldn't do it. – Lasse V. Karlsen Dec 08 '17 at 09:34
  • @LasseVågsætherKarlsen is right either pass the date in or hide it behind some interface (`IDateTimeProvider`) and return whichever dates you like in different cases. – thisextendsthat Dec 08 '17 at 09:56
  • ok I will not do this solution. thank you. – Witchayanin Dec 08 '17 at 15:25

0 Answers0