Use Javascript to click through months - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Use Javascript to click through months

patrick64521patrick64521 worldPosts: 0Member

Hi guys,

I have got a calendar together which displays the days of the month but I'd like to use a couple of javascript buttons on the page to increase and decrease the "$newdate = strtotime('+0 month', $current_month);" to allow the users to click through the different months. Well, this is how I'd do it but I'm open to suggestions on how to click through the months.

Any help would be amazing. Thank you for reading this.



$current_month = time();

$newdate = strtotime('+0 month', $current_month);

$day = date('d', $newdate) ;
$month = date('m', $newdate) ;
$year = date('Y', $newdate) ;

$first_day = mktime(0,0,0,$month, 1, $year) ;

$title = date('F', $first_day) ;

 $day_of_week = date('D', $first_day) ; 


 case "Mon": $blank = 0; break; 

 case "Tue": $blank = 1; break; 

 case "Wed": $blank = 2; break; 

 case "Thu": $blank = 3; break; 

 case "Fri": $blank = 4; break; 

 case "Sat": $blank = 5; break; 

 case "Sun": $blank = 6; break; 


 $days_in_month = cal_days_in_month(0, $month, $year) ; 

 $day_count = 1;

 while ( $blank > 0 ) 


 echo "<div class=\"spacer\">
          <a href=\"#\"></a>

 $blank = $blank-1; 



 $day_num = 1;

 while ( $day_num <= $days_in_month ) 


 echo "<div class=\"number_block\">
          <a href=\"#\">$day_num</a>




Sign In or Register to comment.