Get first and last date of preview month


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function select_preview_month() {
  2. var now = new Date(2009,2,1);
  3. var first_day = new Date(now.getFullYear(), now.getMonth(), 1);
  4. var last_day = new Date(now.getFullYear(), now.getMonth(), 0);
  5. alert(first_day);
  6. alert(last_day);
  7. alert(first_day.getDate() + '.' + first_day.getMonth() + '.' + first_day.getFullYear());
  8. alert(last_day.getDate() + '.' + first_day.getMonth() + '.' + last_day.getFullYear());
  9. // first_day.getMonth() is not an error !!!
  10. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.