I have got few date format patterns like "yyyymmdd", "yy_mm_dd" etc.
There can be any combination of such patterns.
I have used add_delta_days to find "yyyy", "yy", "mm", "dd" for the current date and saved them to different variables like "$y1", "$y2", "$m1" etc
Quote:
Sample:
$dateformat = 'yyyymmdd';
$Y1 = 2011;
$Y2 = 11;
$m1 = 11; ---- current month november
$d1 = 05; ---- current day
output needed is
20111105
In one line, i want to check if the dateformat has yyyy/yy and replace it with the corresponding variable $y1.
Here the date format has yyyy, so i want to replace it with $y1 which has current year "2011"
i need to check and replace the string with my variable
How can this be done in simple one line?
Any help will be appreciated.Thanks in advance