Page 1 of 1
Generate days of the month
Posted: Tue Apr 20, 2010 1:51 pm
by xionhack
Hello. I want to generate the initial of the day of all the days of a chosen month. Meaning, if I choose this month it will give me:
TFSSMTWTFSSMTWTFSSMTWTFSSMTWTF
Is that clear? Can anybody help me? thanks!
Re: Generate days of the month
Posted: Tue Apr 20, 2010 3:02 pm
by mikosiko
Is that clear? Can anybody help me?
sure... why not?.... her you go :
http://us.php.net/manual/en/ref.datetime.php
Re: Generate days of the month
Posted: Tue Apr 20, 2010 3:09 pm
by xionhack
Honestly, I tried. The only reason why I posted that here is because I havent found the way how to figure it out
Re: Generate days of the month
Posted: Tue Apr 20, 2010 5:23 pm
by pickle
Generate a timestamp for the first day of the month. Then, using that timestamp, find the day of the week & get the first character. Increment your timestamp by 1 day using
strtotime() & repeat. Continue until your timestamp is greater than the timestamp of the last day of the month.
There are probably more efficient ways of doing this with a for loop & arrays, but this'll at least get you started.