Answer the question
In order to leave comments, you need to log in
How to set timezone in Crontab + Php?
Created a task in Cron to update records at exactly 6.00 AM:
0 6-8 * * * php $HOME/yii plan-robot/robot-start
In the controller
$history->date_create=date("Y-m-d H:i:s");
$history->save();
Answer the question
In order to leave comments, you need to log in
When run by cron, the script is run via the CLI, which means changes to Apache2/php.ini will not be used.
Usually there is a separate cli/php.ini file, and set the zone in it.
Also, the zone can be set globally in the script itself
. And of course, I agree with the answer above - it's better to use timestamp - or not to depend on local settings.
date_default_timezone_set('Europe/Moscow');
time()
DateTime::getTimestamp()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question