Skip to main content

Send or stop emails only during a set time period

Send a trigger email only within a set time period or send a different trigger email during a sale.

Updated over 2 weeks ago

To send an email only within a specific time frame, such as during a sale, you can switch the email ID in the Send Email field of a trigger. However, a more effective approach is to set up two triggers that send emails based on when the cart was abandoned.

Send only if a cart is created within a specified date range

For the trigger you want to send during the event, use the following code:

result.proceed = false;

var startDate = new Date('2013-10-09 00:00:00 UTC');

var endDate = new Date('2013-10-09 23:59:59 UTC');

if (cart.dt >= startDate && cart.dt <= endDate) { result.proceed = true; }

Change the startDate and endDate variables to match the date and time of the period you want to send the emails for.

Stop send if a cart is created time within a specified date range

For the trigger you want to stop during an event, use the following code:

result.proceed = true;

var startDate = new Date('2013-10-09 00:00:00 UTC');

var endDate = new Date('2013-10-09 23:59:59 UTC');

if (cart.dt >= startDate && cart.dt <= endDate) { result.proceed = false; }

Time zone considerations

These times must be in the UTC time zone (also known as GMT). You must convert your local time to UTC, taking into account Daylight Saving Time/Summertime.

For example, if you are in Miami and have a sale on October 9, 2013, you would be in Eastern Daylight Time (EDT), which is four hours behind UTC (compared to Eastern Standard Time, which is five hours behind).

Miami (EDT)

UTC

Start Date

2013-10-09 00:00:00

2013-10-09 04:00:00

End Date

2013-10-09 23:59:59

2013-10-10 03:59:59

You can find the current UTC time here and here's an online time zone converter.

Did this answer your question?