question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get single letter abbreviation of week day.

See original GitHub issue

Description of the Issue and Steps to Reproduce:

I need to get single letter abbreviation of week day e.g. R for Thursday, F for Friday, S for Saturday, U for Sunday.

Using moment().format('d') give the number of the day of the week.

Is this supported by moment or can I added explicitly?

Environment:

Chrome 63 on OSX.

Moment version: 2.20.1.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
ashsearlecommented, Feb 1, 2018

The shortest form you can get is 2-letters (in English): moment().format('dd')

I’ve never seen Thursday abbreviated as ‘R’. Have you made that up?

6reactions
ashsearlecommented, Feb 1, 2018

If you’re not going to use the existing minimal weekday abbreviations used by dd, you can use updateLocale to override

moment.updateLocale('en', { weekdaysMin: 'U_M_T_W_R_F_S'.split('_') });
moment().format('dd');

However… I would strongly advise against doing this. I can’t think of any scenario where a 1-character abbreviated weekday makes sense: it makes no sense on a calendar, as dates are 2-digits, and it makes no sense in isolation where ‘T’ and ‘S’ will be confusing abbreviations unless the full set of other characters is known. And, frankly, U and R are ridiculous stand-ins for Sunday and Thursday in any circumstance (both of which contain a ‘U’…)

Read more comments on GitHub >

github_iconTop Results From Across the Web

One Digit Day of Week Abbreviations - EventGuide
One Digit Day Codes ; W, Wednesday ; R, Thursday, Uses "R" to prevent confusion with Tuesday. ; F, Friday ; S, Saturday,...
Read more >
Standard Month and Days of the Week Abbreviations
S or U - Sunday; M - Monday; T or Tu - Tuesday; W - Wednesday; Th or R - Thursday; F -...
Read more >
Is there a single character day of the week convention?
I've usually seen 'H' for Thursday. · ha, I'm used to 'R' for thursday.
Read more >
3, 2 and 1 letter abbreviations for days of the week
3, 2 and 1 letter abbreviations for days of the week · M · T · W · R · F · S...
Read more >
One Letter Abbreviation for the Day of the Week
If you use single letters to represent the day of the week, you will run into problems with Sunday/Saturday and Tuesday/Thursday.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found