I am writing a cron to run at midnight every day in Indian Standard Time.
@Injectable()
export class CronService {
@Cron("0 0 * * *")
async midnightCron() {
// implementation
}
}
My instance is deployed in AWS Mumbai region.
I want to know if the @Cron decorator uses local time or UTC time for execution ?
The cron package that NestJS uses just works based on the TZ environment variable if no timezone is passed to it when scheduling the task. This is a default environment variable that usually reflects the system's clock, but can be set to UTC to have Node's Date class function as if it were always in UTC time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With