Get month name from Date

前端 未结 30 2940
情歌与酒
情歌与酒 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:53

    The natural format this days is to use Moment.js.

    The way to get the month in a string format , is very simple in Moment.js no need to hard code the month names in your code: To get the current month and year in month name format and full year (May 2015) :

      moment(new Date).format("MMMM YYYY");
    

提交回复
热议问题