0

I know this sounds so silly. But I want to set the readonly field DateTime.UtcNow to 01/01/2021. is it possible?
I have an existing application where we have used DateTime.UtcNow heavily. Now the client wants to process the old files.

But we can't change the code in so many places and retest all over again. I was wondering if it's possible to set the DateTime.UtcNow value to a past date so that code will not be impacted.

Please advice. Thanks for your help!!

Biswabid
  • 1,378
  • 11
  • 26
  • 2
    [Related](https://stackoverflow.com/a/36452202/3181933). Realistically, you should change the code instead. – ProgrammingLlama Mar 23 '21 at 04:06
  • 1
    When you do change it, make dates and times an injected service. It makes testing (and what you are talking about) simpler – Flydog57 Mar 23 '21 at 05:29
  • Why would you need to test less if you would change code from UtcNow to something else compared to manipulating UtcNow to be something else, in both cases you change the date don't see the difference to be honest. – Rand Random Mar 23 '21 at 07:39

0 Answers0