We have a scheduled job that runs on the 1st of each month with a Preferred Start Time of 1am. The job was scheduled using the Salesforce interface (Develop | Apex Classes | Schedule Apex). When it runs, it sets a month field for records based on the System date (System.today();
). Occasionally, the month is set wrongly, and I suspect it's due to the date variable set to the System date.
If I set the job to run at 1am, logged in as my User (with a time-zone set to CDT), using the interface, what value would be returned by System.today()
? Would the current CDT date be returned, or the GMT date?
System.today();
in Execute Anonymous, and indeed it does use the current User's Time Zone when returning the date. It returned2012-03-15 00:00:00
. – Cryohydrate