Posted By

Ozzy on 09/16/09


Tagged

month time date


Versions (?)

Get first and last date of preview month


 / Published in: JavaScript
 

  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  

You need to login to post a comment.