adding the day name to date?
https://codepen.io/Laing91/pen/vYrGQWK
Without giving me the actual answer, how would I go about removing the leading zero from the days “01, 02, 03 etc…? I’ve read up on .replace and parseInt but couldn’t quite work out how to implement either into my current code..
16 Replies
how did you get month?
take a look at the
Date
object on mdnHahaha I’m so silly.. thanks 🙂
New issue: how to remove the 0 from 01, 02 etc…I’ve read up on parseInt and also .replace but not sure which one works for my current code as I did try to implement both with not much luck.. I’m wanting to change it so it reads “Thursday, 3rd” basically. I know how to add the st, th, rd, just need to remove the leading zero.
what do you use to get the 03? Because if you do date.getDate() you should get a number
oops, my bad thought I read how to add not remove 😅
it happens
If you still want to use your own method instead of relying on MarkBoots solution, you can use .replace() providing a regular expression. You can use this to detect leading zeroes in front of single digits.
here my a way how you could do it without a lookup table for month names / weekday names
(only look if you want, otherwise just ignore)
https://codepen.io/MarkBoots/pen/ExRKMMY?editors=1011
Sorry I was tweaking my code and ended up replacing the old one and couldn’t get it back hahahaha
That’s exactly what I was looking for, thanks 🙂
Https://Codepen.io/Laing91/pen/jOkqRPX
Thanks haha
Using the new Intl API, fancy 😎
I still need to look into it
i was hoping to get more options for custom formatting (declare a pattern or something, but that's not a thing yet)
I haven’t seen that concept, it’s pretty cool. I just wish I had my original attempt at this saved so I could show my mentor my first go then my refined go lol
nothing is waisted. you learned on the way
Oh for sure I really enjoyed that learning experience
Thanks a lot for the help
no problem, good luck!