…meie igapäevast IT’d anna meile igapäev…

2010-02-02

JavaScript dates: get Monday, get Sunday, get last day of a month

  1. function getMonday(d)
  2. {
  3.     return new Date(d.getFullYear(), d.getMonth(), d.getDate() – d.getDay() + 1);
  4. }
  5. function getSunday(d)
  6. {
  7.     return new Date(d.getFullYear(), d.getMonth(), d.getDate() – d.getDay() + 7);
  8. }
  9. function getLastDayOfMonth(d)
  10. {
  11.     return new Date(d.getFullYear(), d.getMonth() + 1, 0);
  12. }

Lisa kommentaar »

Kommentaare veel pole.

RSS feed for comments on this post. TrackBack URI

Lisa kommentaar

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Muuda )

Twitter picture

You are commenting using your Twitter account. Log Out / Muuda )

Facebook photo

You are commenting using your Facebook account. Log Out / Muuda )

Google+ photo

You are commenting using your Google+ account. Log Out / Muuda )

Connecting to %s

Blog at WordPress.com.