I need to process a file by adding to it, but then saving as separate weekly files.
It is easy to do monthly, which I am doing as follows:
// Set variables
$month = date('m');
$year = date('Y');
// Load previous file content
$newreportfile = file_get_contents('/var/www/html/reports/' . $year . "_" . $month . "_report.csv");
// Add new content
$file_to_write = $newreportfile . $report_log;
// Write file back
file_put_contents('/var/www/html/reports/' . $year . "_" . $month . "_report.csv", $file_to_write);
This works fine for keeping it all in a monthly file, but how could I do this to have it in a weekly format, specifically breaking the files on a particular day of week at a particular time (Sunday 23:59:59)?
Any guidance on the best way to do this would be appreciated.
Thank you.