It is currently Nov 30th 2020 20:36 GMT-6.
I just started getting errors in my test code and found something interesting. After some investigating, I found the Date.Today().Month() in my test code is returning 12 (December) even though it is still 11 (November). I checked my personal time zone and company time zone. Both are GMT-6.
I then tried running system.debug(Date.Today().Month()) in the execute anonymous window and it returned the expected 11 (November).
Any idea why this same function returns two different values depending on where it is executed? Is test code run in UTC time zone? It will be good know for future cases!
System.debug
always returns in GMT, so but your code might be running in User Context. Can you show us the code, just to understand where and how are you using the date. – Nagendra Singh Dec 1 '20 at 6:01