Skip to content
Fix Code Error

Get month name from Date

March 13, 2021 by Code Error
Posted By: Anonymous

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");

Solution

Shorter version:

const monthNames = ["January", "February", "March", "April", "May", "June",
  "July", "August", "September", "October", "November", "December"
];

const d = new Date();
document.write("The current month is " + monthNames[d.getMonth()]);

Note (2019-03-08) – This answer by me which I originally wrote in 2009 is outdated. See David Storey’s answer for a better solution.

Answered By: Anonymous

Related Articles

  • ternary operator usage within v-bind class
  • Setting scale_x_discrete limits removes both…
  • Trouble with Next js + Express deployment using Zeit Now
  • Apache server keeps crashing, "caught SIGTERM,…
  • pandas select top N values for each multi index group
  • Couldn't connect to server 127.0.0.1:27017
  • How do I include certain conditions in SQL Count
  • vue.js referencing constants in data?
  • pandas create a column that is a duplicate of the index
  • vuejs conditional binding a class based on the data
  • add scroll bar to table body
  • How to add a unique id to an array in one loop…
  • Javascript code for showing yesterday's date and todays date
  • what is the size of an enum type data in C++?
  • Using two values for one switch case statement
  • Why does `this` inside filter() gets undefined in VueJS?
  • How do I add Internet Explorer 10 support to a…
  • How to get the day of week and the month of the year?
  • unstack start and end date to month
  • Android Gradle plugin 0.7.0: "duplicate files during…
  • Get a list of dates between two dates
  • Ordering dates in R with lubridate
  • Dodged bar plot in R based on to columns with count…
  • R: How can I create rows based on the values of other rows?
  • Detect if Visual C++ Redistributable for Visual…
  • How do I calculate the date in JavaScript three…
  • Current time formatting with Javascript
  • Sorting a 2D string array in c
  • how to sort pandas dataframe from one column
  • sort array of date-months in ascending order of type string
  • Python JSON TypeError : list indices must be…
  • C++ Need help sorting a 2D string array
  • Difference in Months between two dates in JavaScript
  • Subtract three rows from an array in angular 7
  • Awk sort by last column and the print the whole line
  • lag on a lag, PostgreSQL (obtaining the value 2…
  • cumulative sum before, sum after
  • Disabling a button upon condition in Google App script
  • How to get current formatted date dd/mm/yyyy in…
  • How to get 30 days prior to current date?
  • Genymotion, "Unable to load VirtualBox engine." on…
  • how to use canvas in JavaScript flappy bird code
  • DAX Function Using Variables for Efficiency Purposes
  • How to save all repeated loop results in R in a dataframe
  • Difference between Eclipse Europa, Helios, Galileo
  • What are the correct version numbers for C#?
  • Peak signal detection in realtime timeseries data
  • How could generate a numerical value on Time?
  • Creating a single column of dates from a column of…
  • How to read multiple files stored in a given folder…
  • Mongod complains that there is no /data/db folder
  • How to use temporary table in the from clause in mysql?
  • How to change date format in JavaScript
  • Backbone.js Model, adding setInterval correctly
  • Group array of objects by multiple keys using d3.groups
  • Backbone.js rendering a reset collection with a single view
  • Polymer nested dom-repeat templates are not updating…
  • Load json file with string into pandas dataframe in python
  • Converting year and month ("yyyy-mm" format) to a date?
  • Event listener is not working for textbox
  • Java string to date conversion
  • setTimeout function not working : javascript
  • What does this symbol mean in JavaScript?
  • Change language for bootstrap DateTimePicker
  • Merge two Dataframes with different structures
  • "[notice] child pid ✘✘✘X exit signal Segmentation…
  • How to auto insert the current user into my db when…
  • How to get the date a status changes in a time series?
  • Sort table rows In Bootstrap
  • Javascript dynamic sorting array of object include…
  • How do I set the selected item in a drop down box
  • how to create multiple chart on one component vue
  • JavaScript TypeError: Cannot read property 'style' of null
  • Backbone Model is undefined in item View after initial load
  • Why ChartJs is not working in IE
  • charts.js stacked bar with polymer's wrapper chart-elements
  • Oracle listener not running and won't start
  • Sort a two dimensional array based on one column
  • Using `date` command to get previous, current and next month
  • calculating the difference in months between two dates
  • Redshift: Using DATE_TRUNC makes duplicated rows
  • How to properly use the "choices" field option in Django
  • Is it possible to style different sections of…
  • Check synchronously if file/directory exists in Node.js
  • How to use v-model with nested properties in Vue.js
  • Trigger child component method from parent event
  • Efficiency of Java "Double Brace Initialization"?
  • How can I convert a comma-separated string to an array?
  • Vue and Chartjs - Running a simple example of vue-chartjs
  • The data property is already declared as a prop
  • VueJs, Vue-chartjs - mutating props
  • How do i update a javascript variable as its value changes?
  • JavaScript function to add X months to a date
  • python 3.2 UnicodeEncodeError: 'charmap' codec can't…
  • How to reliably get previous month from js Date?
  • Mysql Compare two datetime fields
  • Excel: Generating Months Data from Start and End Date
  • How do you filter on specific values of a column in…
  • Maven2: Missing artifact but jars are in place
  • Converting date from user input from 'mm/dd/yyyy' to…

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Post navigation

Previous Post:

python: SyntaxError: EOL while scanning string literal

Next Post:

How to create dictionary and add key–value pairs dynamically?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

.net ajax android angular arrays aurelia backbone.js bash c++ css dataframe ember-data ember.js excel git html ios java javascript jquery json laravel linux list mysql next.js node.js pandas php polymer polymer-1.0 python python-3.x r reactjs regex sql sql-server string svelte typescript vue-component vue.js vuejs2 vuetify.js

  • you shouldn’t need to use z-index
  • No column in target database, but getting “The schema update is terminating because data loss might occur”
  • Angular – expected call-signature: ‘changePassword’ to have a typedeftslint(typedef)
  • trying to implement NativeAdFactory imports deprecated method by default in flutter java project
  • What should I use to get an attribute out of my foreign table in Laravel?
© 2022 Fix Code Error