I'm trying to create a new cron tab on the fly, and running into problems with the times created by the cron model. Here is an example:
So first let's use config.xml
to create some cron tabs:
<crontab>
<jobs>
<erp_cron_tab>
<schedule><cron_expr>* * * * *</cron_expr></schedule>
<run>
<model>erp/observer::cronTab</model>
</run>
</erp_cron_tab>
</jobs>
</crontab>
As soon as I hit cron.php
Magento creates 20 new rows in the cron_schedule
table. At the time of writing this, the created_at
time is 2014-07-24 19:17:16
I now try to create my own cron tab "manually" through the model, like so:
Mage::getModel('cron/schedule')
->setJobCode('erp_cron_tab')
->setScheduledAt(date('Y-m-d H:i:00', Mage::getModel('core/date')->timestamp(time())))
->save();
Now all of a sudden the created_at
time is 2014-07-24 12:17:16
a whole 7 hours earlier.
Shouldn't I be avoiding timezone issues by using Mage::getModel('core/date')->timestamp(time())
? Why do these times not line up?