Right now the file is being renamed with the current month (June), when it should be the previous month. Can anyone suggest how I would alter this code for the desired output? I tried F-1 but it didnt work, it said June 1 instead of the month before.
Code:
rename ("C:\Smurf_Reports\mssql\Monthly_Stats\monthly_mssql.csv", "C:\Smurf_Reports\mssql\Monthly_ Stats\old\monthly_mssql_" . date("m_Y") . ".csv");
You can use date()
, just simply subtract one month:
rename("C:\Smurf_Reports\mssql\Monthly_Stats\monthly_mssql.csv", "C:\Smurf_Reports\mssql\Monthly_Stats\old\monthly_mssql_" . date("m_Y", strtotime("-1 month")) . ".csv");
As of today, would rename the file to: "C:\Smurf_Reports\mssql\Monthly_Stats\old\monthly_mssql_05_2013.csv
You want to tell the date function to use the previous month
rename ("C:\Smurf_Reports\mssql\Monthly_Stats\monthly_mssql.csv", "C:\Smurf_Reports\mssql\Monthly_ Stats\old\monthly_mssql_" . date("m_Y",strtotime('-1 month')) . ".csv");