Jquery – Get month text from date

You can use jQuery to generate the texts from date, month, or year. Here is an example:

let date = new Date(2021, 06, 21); // 2021-06-21
let longMonth = date.toLocaleString(‘en-us’, { month: ‘long’ }); /* June */
let shortMonth = date.toLocaleString(‘en-us’, { month: ‘short’ }); /* Jun */
let narrowMonth = date.toLocaleString(‘en-us’, { month: ‘narrow’ }); /* J */

Revisions

No comments yet.

Leave a Reply