Tuesday, 15 July 2014

mysql - display last days of previous month php -



mysql - display last days of previous month php -

i searched millions of similar posts cannot find how create count downwards 31, 30, 29, 28 etc.

i can have previous calendar blocks show 31st that's all. need show previous month 31st, 30, 29, etc.

updated code renku:

//define variable daycol $daycol = 0; // print lastly months' days spots. ($i=0; $i<$leadindays; $i++) { $lastmonth = date('d', strtotime(-$i.' day', strtotime($startdate))); // days in previous month print "<td width=\"14%\" height=\"25%\" class=\"calendar_cell_disabled_middle\">$lastmonth</td>\n "; $daycol++; }

example :

i writing new loop this.

<?php $startdate= date("y-f-d",strtotime("+0 month"));// first day of current month $num= 10; // how many past days need previous month + 1 (to remove current day) ($i=1; $i<$num; $i++) { echo $prev= date('y-m-d', strtotime(-$i.' day', strtotime($startdate)))."<br />"; //get lastly days of previous month } ?>

i re writing loop,

<?php $daycol = 0; $leadindays = 5; // (just feb cuz theres 5 blanks before 1st of feb) $startdate= date("y-f-d",strtotime("+0 month")); // print lastly months' days spots. ($i=1; $i<($leadindays+1); $i++) { $lastmonth = date('d', strtotime(-$i.' day', strtotime($startdate))); // days in previous month print "<td width=\"14%\" height=\"25%\" class=\"calendar_cell_disabled_middle\">$lastmonth</td>\n "; $daycol++; } ?>

test here

php mysql

No comments:

Post a Comment