Today I’ll talk about a problem that I had when I wanted to compare dates.
The problem I had was that the time displayed was different from the time that I was recovering through my code! 2h difference to be exact.
After searching for a long time, it turns out that the “problem” was how SharePoint stores dates. Indeed SharePoint converts dates to UTC … that’s why my comparison was not good!
So when you want to work in code behind with dates, do not forget to convert to UTC!
For this, two methods:
I met the problem on a 2010 environment but in my opinion it should be the same in 2007 and 2013.
Hope this helps!