Forum Moderators: coopster
$date = array(date("d.m.y",strtotime("-6 month")),
date("d.m.y",strtotime("-5 month")),
date("d.m.y",strtotime("-4 month")),
date("d.m.y",strtotime("-3 month")),
date("d.m.y",strtotime("-2 month")),
date("d.m.y",strtotime("-1 month")),
date("d.m.y"));
and
$date = array(date("d.m.y",mktime(0,0,0,date("m")-6,date("d"),date("Y"))),
date("d.m.y",mktime(0,0,0,date("m")-5,date("d"),date("Y"))),
date("d.m.y",mktime(0,0,0,date("m")-4,date("d"),date("Y"))),
date("d.m.y",mktime(0,0,0,date("m")-3,date("d"),date("Y"))),
date("d.m.y",mktime(0,0,0,date("m")-2,date("d"),date("Y"))),
date("d.m.y",mktime(0,0,0,date("m")-1,date("d"),date("Y"))),
date("d.m.y",mktime(0,0,0,date("m"),date("d"),date("Y"))));
will output this:
Array
(
[0] => 31.07.04
[1] => 31.08.04
[2] => 01.10.04
[3] => 31.10.04
[4] => 01.12.04
[5] => 31.12.04
[6] => 31.01.05
)
also, this function
echo date("d.m.y",mktime(0,0,0,1,0,2005));
will output this:
31.12.04
I wasn't expecting these results, I could retool the code checking the days of the month using date("t") but it's not a very good solution.
I also have a script that will go through a text file, and it will start writing when it finds a matching date, then stop writing from the file when it encounters a date that isn't a matching date.
The current code I've got works quite well, but I sometimes get a false match for a date if there is an odd combination of numbers and characters. Is it possible to recognise a date only if it is in a specific format, date("l dS of F Y H:i:s") for example.
Many thanks.
That also means that the "31st" of a month with 30 days will be the "1st" of the next month (or in the case of February either the "2nd" or "3rd" of Match).
Hope that helps ;)
I don't use the date, only the month and the year, I'll specify a value of one for the day to keep the month like this:
date("M Y",mktime(0,0,0,date("m")-5,1,date("Y")));
Question is, what if you need the date? The date("m") returns the month, the date("Y"), returns the year, why not the date("d"), am I missing something?
Now I just need to figure out the second problem...
Still not sure why date("d") returns 0, then shouldn't date("Y") return 0 as in 1970?