gpt4 book ai didi

asp.net-mvc - UTC 时间的 Hangfire CRON

转载 作者:行者123 更新时间:2023-12-02 06:15:31 25 4
gpt4 key购买 nike

我正在尝试在我的 MVC 应用程序中配置一个从每天 00:00 开始的重复任务。我知道这可以通过RecurringJob.AddOrUpdate(() => Console.Write("Easy!"), Cron.Daily);来实现。现在我的问题是hangfire cron 是否根据UTC 时间或服务器本地时间工作。如果它在本地时间上运行,有没有办法在 UTC 时间上运行它?我必须这样做,因为这将是一个日终流程,并且所有计划任务都是根据我数据库中的通用时间安排的。

最佳答案

要在 UTC 时区执行作业,您可以在定义作业时将 TimeZoneInfo 提供为 TimeZoneInfo.Utc

RecurringJob.AddOrUpdate(() => Console.Write("Easy!"), Cron.Daily, TimeZoneInfo.Utc);

要在本地时区执行作业,您可以使用TimeZoneInfo.Local

关于asp.net-mvc - UTC 时间的 Hangfire CRON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38282769/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com