function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Gopikrishna DasariGopikrishna Dasari 

I have schedule apex I want to schedule for IST 8 AM and 8 AM UTC and 8 AM GMT How can we do this?

anyone can help me with this?
VinayVinay (Salesforce Developers) 
Hi Gopikrishna,

You would need to convert your time zone and consolidate in one format and execute them 3 or 4 times a day as per your requirement.  Below is sample logic that executes every 4 hours in single day.
public class Scheduleclass implements Schedulable{
public void execute(SchedulableContext sc){
// your code here
}
}
Below is the format to schedule apex job.
system.schedule('CRON SET','0 0 0/4 1/1 * ? *',new Scheduleclass());
References:
https://www.desynit.com/dev-zone/salesforce-development/how-do-i-schedule-apex-programmatically/
https://medium.com/salesforce-champion/schedule-apex-salesforce-ui-and-cron-expression-asynchronous-apex-aaba0e1f981e

Please mark as Best Answer if above information was helpful.

Thanks,
Andrea Smith 12Andrea Smith 12
Hi Gopi Krishna,
Scheduling an Apex job for specific times in different time zones requires considering the time zone offsets.To schedule the job, you'll need to use the System.schedule method in Apex. Here's an example of how you could set this up:

apex
Copy code
Datetime now = Datetime.now();
Integer offsetIST = 5 * 60 + 30; // IST offset in minutes

Datetime targetTimeIST = Datetime.newInstance(
    now.year(), now.month(), now.day(),
    8, 0, 0
).addMinutes(-offsetIST);

Datetime targetTimeUTC = Datetime.newInstance(
    now.year(), now.month(), now.day(),
    8, 0, 0
);

// Schedule the jobs
String jobNameIST = 'MyJobIST';
String jobNameUTC = 'MyJobUTC';

System.schedule(jobNameIST, CronExpressionGenerator(hour = targetTimeIST.hour(), minute = targetTimeIST.minute()));
System.schedule(jobNameUTC, CronExpressionGenerator(hour = targetTimeUTC.hour(), minute = targetTimeUTC.minute()));
In this example, CronExpressionGenerator is a hypothetical method to create a Cron expression with the given hour and minute.

By following these steps, you'll have your Apex job scheduled to run at 8 AM in IST, UTC, and GMT. Just make sure to replace the example code with your actual job implementation and proper scheduling syntax.

Remember to consider daylight saving time changes if applicable to the time zones you're working with.

I hope this helps you achieve your scheduling requirements! If you have any further questions, feel free to ask.





 
Victor marcel 9Victor marcel 9
To schedule your Apex job for IST 8 AM, UTC 8 AM, and GMT 8 AM, you can use the Cron expression "0 0 8 ? * *". This expression will run the job at 8 AM in the specified time zones.
Follow My Health (https://www.followmy-health.com/)
afrs siabafrs siab
To schedule an Apex job at 8 AM in IST, UTC, and GMT:
Schedule it at 8 AM UTC in Salesforce.
Calculate the equivalent times: 1:30 PM IST and 8 AM GMT.
Schedule additional jobs at those calculated times for IST and GMT.
Also visit my website (https://athgardens.com/).