get number of day in javascript date object

21,265

Solution 1

You're looking for .getDate():

new Date().getDate();

.getDay() returns the day number 0 (Sunday) to 6 (Saturday).

Solution 2

The one you are looking for is .getDate(), not .getDay()

Date Object Reference

Solution 3

You should use

new Date().getDate()

Solution 4

getDay and getUTCDay returns the number of the weekday. You need getDate() and etUTCDate()

Share:
21,265

Related videos on Youtube

puchu
Author by

puchu

Updated on July 05, 2022

Comments

  • puchu
    puchu almost 2 years
    //27 <- today day number
    new Date().getDay() = new Date().getUTCDay() //<- 5 (friday)? what?
    

    Do I have to parse the result with .toString() or use something like YUI.Date.format()?

    • Jason
      Jason almost 12 years
      ^ I just had the same thought myself; couldn't resist upvoting.