I have a scheduler that has to run on 12:00 AM of Indian time zone and 12:00 AM of Singapore timezone. I was able to write a cron job for Indian users, But how to trigger the same in Singapore at 12:00 AM?
Asked
Active
Viewed 2,693 times
2 Answers
10
if you use this method, only one time you need to write the code, and call it from two functions that decorated by @Cron()
service.ts
@Injectable()
export class Service {
@Cron('* * 0 * * *', {
timeZone: 'Asia/Tehran', // use this website: https://momentjs.com/timezone/
})
async iran() {
this.yourFunction();
}
@Cron('* * 0 * * *', {
timeZone: 'Asia/Tokyo',
})
async japan() {
this.yourFunction();
}
async yourFunction() {
// write the schedule only one time
}
}

ehsan mandegar
- 319
- 1
- 8
0
I think easily use for example 9:30 PM (UTC+08:00(Singapore) - UTC+05:30(India)) AM instead of 12:00 AM

ehsan mandegar
- 319
- 1
- 8
-
Yes, For that I need two separate schedulers with repeated code. In future, we will support multiple timezones. Then the solution is not feasible – Balaji Venkatraman May 19 '21 at 15:00
-
whebn you are setting time to start, set two times, for India and singapour – ehsan mandegar May 20 '21 at 08:10
-
but let me write the code and show you how. – ehsan mandegar May 20 '21 at 08:24