TimerTrigger with time range is not using UTC
I have an issue that seems to suggest that TimerTriggers with time ranges running locally (with func start) are ignoring the expected timezone.
This is my code:
public static class TestTimer {
[FunctionName("TestTimer")] public static async Task RunAsync([TimerTrigger("*/30 * 19-21 * * *")] TimerInfo myTimer, ILogger log) {
log.LogInformation($"C# Timer trigger function executed at: {DateTime.UtcNow}");
}
}
I also added this to host.json for additional logging:
"logging": {
...
"fileLoggingMode": "always",
"logLevel": {
"Function": "Trace",
"default": "Trace"
}
}
Running with func start logs this:

Highlighted in yellow are UTC times, green localtime and blue is 'expected UTC time'.
As you can see from the timestamps on the far left, the process ran at 19:44 UTC which is within the time rage of 19-21. But the function scheduler ignores this and instead schedules the next 5 function triggers for 19:00 local time.
Note: I have not overridden WEBSITE_TIME_ZONE so TZ should be UTC. And even if I do explicitly set WEBSITE_TIME_ZONE to 'UTC' or 'GMT Standard Time' this still occurrs.
@gatapia can you expand on your scenario? Today the timer trigger always uses the environment timezone, which is what WEBSITE_TIME_ZONE controls when hosted on Azure. For local tests, the same applies and the local machine configuration is applied.
WEBSITE_TIME_ZONE is ignored when working out the cron schedules when running locally:

The above shows that I set the WEBSITE_TIME_ZONE to 'UTC'. This can be seen in the last highlighted item where I simply wrote out the env variable:
Console.WriteLine("WEBSITE_TIME_ZONE: " + Environment.GetEnvironmentVariable("WEBSITE_TIME_ZONE"));
This prints UTC as expected. However, the cron job explicitly says (highlighted in green):
The 'function_name' ... and the local time zone: '(UTC+10:00) Canberra, Melbourne, Sydney'
And as I mention on my original post, if I use a more complex cron expression with a time range such as '*/30 0 0-10 * * *' then the time range will be in the local time zone even if WEBSITE_TIME_ZONE is specified.
ping: @fabiocav !
Hi there, any news on that issue? I have the same problem.
I did a test with my timer to trigger at 08:16:00 UTC every weekday, setting the WEBSITE_TIME_ZONE to UTC, but when I run locally in my time zone (UTC-05:00), it triggers at 08:16:00 local time (13:16:00 UTC) When deployed to Azure, it triggers fine at 08:16 UTC as expected.
This is the trigger:
[FunctionName("MyTriggerFunction")]
public async Task Run([TimerTrigger("0 16 8 * * 1-5")] TimerInfo myTimer, ILogger log)
{
log.LogInformation("WEBSITE_TIME_ZONE: " + Environment.GetEnvironmentVariable("WEBSITE_TIME_ZONE"));
The environment variable in my launchSettings.json: "WEBSITE_TIME_ZONE": "UTC",
And the log:
[2022-09-01T13:15:32.992Z] The next 5 occurrences of the 'MyTriggerFunction' schedule (Cron: '0 16 8 * * 1-5') will be:
[2022-09-01T13:15:32.994Z] 09/01/2022 08:16:00-05:00 (09/01/2022 13:16:00Z)
[2022-09-01T13:15:32.995Z] 09/02/2022 08:16:00-05:00 (09/02/2022 13:16:00Z)
[2022-09-01T13:15:32.997Z] 09/05/2022 08:16:00-05:00 (09/05/2022 13:16:00Z)
[2022-09-01T13:15:32.998Z] 09/06/2022 08:16:00-05:00 (09/06/2022 13:16:00Z)
[2022-09-01T13:15:33.001Z] 09/07/2022 08:16:00-05:00 (09/07/2022 13:16:00Z)
[2022-09-01T13:15:33.003Z]
[2022-09-01T13:15:33.010Z] Host started (730ms)
[2022-09-01T13:15:33.011Z] Job host started
[2022-09-01T13:15:37.161Z] Host lock lease acquired by instance ID '000000000000000000000000D00DA1BA'.
[2022-09-01T13:16:00.999Z] Executing 'MyTriggerFunction' (Reason='Timer fired at 2022-09-01T08:16:00.0133002-05:00', Id=9c9b3ae6-f261-4613-b1d4-d30942f74d1c)
[2022-09-01T13:16:02.331Z] WEBSITE_TIME_ZONE: UTC