Get month name from Date

前端 未结 30 2946
情歌与酒
情歌与酒 2020-11-22 00:16

How can I generate the name of the month (e.g: Oct/October) from this date object in JavaScript?

var objDate = new Date(\"10/11/2009\");
30条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-22 00:58

    You might use datejs to do that. Check the FormatSpecifiers, MMMM gives you the month's name:

    var objDate = new Date("10/11/2009");
    document.write(objDate.toString("MMMM"));
    

    And datejs got that localized for more than 150 locales! See here

提交回复
热议问题