You are viewing an old revision of this post, from November 18, 2021 @ 20:08:59. See below for differences between this version and the current revision.

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

  • November 18, 2021 @ 20:09:32 [Current Revision] by Sharing Solution
  • November 18, 2021 @ 20:09:32 by Sharing Solution
  • November 18, 2021 @ 20:08:59 by Sharing Solution

Revision Differences

November 18, 2021 @ 20:08:59Current Revision
Content
Unchanged: You can use jQuery to generate the texts from date, month, or year. Here is an example: Unchanged: You can use jQuery to generate the texts from date, month, or year. Here is an example:
Deleted: let date = new Date(2020, 05, 21); // 2020-06-21  Added: let date = new Date(2021, 06, 21); // 2021-06-21
Unchanged: let longMonth = date.toLocaleString('en-us', { month: 'long' }); /* June */ Unchanged: let longMonth = date.toLocaleString('en-us', { month: 'long' }); /* June */
Unchanged: let shortMonth = date.toLocaleString('en-us', { month: 'short' }); /* Jun */ Unchanged: let shortMonth = date.toLocaleString('en-us', { month: 'short' }); /* Jun */
Unchanged: let narrowMonth = date.toLocaleString('en-us', { month: 'narrow' }); /* J */ Unchanged: let narrowMonth = date.toLocaleString('en-us', { month: 'narrow' }); /* J */

Note: Spaces may be added to comparison text to allow better line wrapping.

No comments yet.

Leave a Reply