How to get the day from a particular date using JavaScript

前端 未结 3 646
情歌与酒
情歌与酒 2020-12-07 01:29

I am new to JavaScript. My requirement is that T want to pop up a message on particular days (like Sunday, Monday...) all through when a date is selected.

I tried

3条回答
  •  失恋的感觉
    2020-12-07 02:14

    This page seems to provide you with what you need.

    What we are going to do is to add getMonthName() and getDayName() methods to all our dates so that we can get the month name or day name by calling these new methods directly instead of having to call getMonth() or getDay() and then do an array lookup of the corresponding name.

    You can then do:

    var today = new Date;
    alert(today.getDayName());
    

提交回复
热议问题