The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

API Error:"Scheduled date is before the current time."

Highlighted
Occasional Contributor

API Error:"Scheduled date is before the current time."

Hi,

 

We're currently using the API to create campaigns, and all seems to be working fine.  When we try to schedule the campaign, however, we are getting errors.  When we try to use the example format for 'schedule_date' from one of the SDK libraries:

 

$time =  date('Y-m-d\TH:i:s\.000\Z', strtotime("+1 hour"));

$schedule = new Schedule();
$schedule->scheduled_date = $time;

 

We get an error that the "Scheduled date is before the current time."   When we echo the $time to the screen, we see that it is in fact one hour in the future. (We are in EST).

 

When we try to use the standard PHP format for ISO-8601  (lowercase 'c') we get and error that  "#/scheduled_date: Value is not a valid ISO-8601 date time format."

 

$dt =  date('c', strtotime("+1 hour"));

$schedule = new Schedule();
$schedule->scheduled_date = $dt

 

I'm sure there is something obvious we are missing, so any help would be greatly appreciated.

 

3 REPLIES 3
Highlighted
Moderator

Re: API Error:"Scheduled date is before the current time."

The first option you are using puts the time in GMT, so if it is one hour in the future it would actually be 4 hours in the past if you're using the current EST time stamp (GMT being 5 hours before EST).  For example, if you tell us to schedule the email at 4AM GMT and it's currently 3AM EST, it's really 8AM GMT and that timestamp is wrong.  If you want to provide the time to us in EST, that is certainly possible.  However, it would require an offset added at the end of -05:00 instead of z, z indicating we should treat that as Zulu time or GMT.

 

The second sounds like a potential bug.  Could you please share the time format as you're trying to send it using an echo or print option?  We should be inclusive of virtually all 8601 formats and if we are missing some, we are more than happy to take a peak at that bug.

Dave Berard
Senior Product Manager, Constant Contact
Highlighted
Occasional Contributor

Re: API Error:"Scheduled date is before the current time."

Hi - below is how we are setting the variables in our PHP code, along with the respective echo:

 

$time = date('Y-m-d\TH:i:s\.000\Z', strtotime("+1 hour"));
$phpTime = date('c', strtotime("+1 hour")).;

 

schedule time: $time 2013-11-11T12:46:40.000Z
schedule time: $phpTime 2013-11-11T12:46:40-05:00

 

We've tried to use the offset (-05.00) for the first option in a number of different ways, however we are still getting an error telling us it is not a valid format.  Can you please provide the syntax that we should be testing to offset the $time variable to EST?

 

Thanks

Highlighted
Moderator

Re: API Error:"Scheduled date is before the current time."

We do currently have a bug that is incorrectly requiring milleseconds for the time stamp (which is why the php time is not working).  We're hoping to have the fix out for this bug soon.  The first time you provided is very different than the second though.  The first time stame is 12:46:40 GMT, which is 7:46:40 EST.  If you are posting this at 12:46:40 EST, than this is certainly actually posting a time that is in the past.  You wuold need to pad by a much larger time stamp (at least 5 hours) if you're not taking into account the time zone difference through a time object.

Dave Berard
Senior Product Manager, Constant Contact
Developer Portal

View API documentation, code samples, get your API key.

Visit Page

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured