Answer the question
In order to leave comments, you need to log in
How to calculate the start date of a period?
In the specified piece of code, the current date is automatically taken every day and 1 day is subtracted, and thus a report for the past day is then generated. You need to change the code so that it takes the entire period from the current day to the beginning of the current month (every month).
How to implement correctly?
/** @var Companies $company */
$company = Companies::model()->findByPk(self::COMPANY_ID);
$model = new Avr();
$model->company = $company->name;
$date = new DateTime();
$model->end = strtotime($date->format('Y-m-d') . ' 23:59:00');
//$model->end = date('d.m.Y H:i:s', $model->end);
$date->modify('-1 day');
$model->start = strtotime($date->format('Y-m-d') . ' 00:00:00');
//$model->start = date('d.m.Y H:i:s', $model->start);
$model->type = 2;
$model->project = ' ';
$model->created_by = self::UNILEVER_USER;
$model->title = Yii::t('main-ui', 'AVR').': '.Avr::companyList($model->company);
$model->params = CJSON::encode($model->attributes);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question