Below method is tweaked to take account of December. This method is leap-year safe. The day count must include floor().
1 2 3 4 5 6 7 8 | $curMonth = date ( 'n' ); $curYear = date ( 'Y' ); if ( $curMonth == 12) $firstDayNextMonth = mktime (0, 0, 0, 0, 0, $curYear +1); else $firstDayNextMonth = mktime (0, 0, 0, $curMonth +1, 1); echo floor ( $daysTilNextMonth = ( $firstDayNextMonth - time()) / (24 * 3600)); |
From above mktime calculation, not only get the number of days, we can count the hours and minutes till next month first day. Example:
1 2 3 | $day_count = floor (( $firstDayNextMonth - time()) / (24 * 3600)); $hour_count = floor (( $firstDayNextMonth - time()) / (3600)); $minute_count = (( $firstDayNextMonth - time()) / (60)); |
Thanks for the great list�I ll definitely try Wordbook to publish my blog posts directly to my facebook
Appreciate this post. Will try it out.
Here is my page Irritable Bowel Syndrome Diet