How to Format Dates with Vanilla JavaScript

  Рет қаралды 6,216

Coding in Public

Coding in Public

Жыл бұрын

You don’t need a library to format dates in JavaScript. Many basic formatting needs are available using the toFormatDateString method based on the Intl API. And it couldn’t be easier to do!
🔗 Key Links 🔗
- MDN Docs: developer.mozilla.org/en-US/d...
---------------------------------------
📹 Related Videos 📹
- Formatting lists and numbers in JavaScript with the Intl API: • Formatting lists and n...
---------------------------------------
🌐 Connect With Me 🌐
- Website: codinginpublic.dev
- Blog: chrispennington.blog
- Twitter: / cpenned
- Patreon: / coding_in_public
- Buy Me a Coffee: www.buymeacoffee.com/chrispen...

Пікірлер: 24
@JosephCodette
@JosephCodette Жыл бұрын
Datetime is such a fundamental thing in programming. For a restaurant site I made I had to make a modal that showed if they were open or not and it seemed simple at first but it was actually quite a puzzle. Things like this make it easier, so thnx! :)
@CodinginPublic
@CodinginPublic Жыл бұрын
Agreed! I am really excited for the temporal API! It’ll make date/time math much easier, too! Hoping to explore it soon!
@neontuts5637
@neontuts5637 Жыл бұрын
Thanks for sharing Chris 🙏. Now no need of using packages to format dates in JavaScript. And it is easy to implement.
@CodinginPublic
@CodinginPublic Жыл бұрын
Glad it was a help! Yep! And especially once the temporal API is really up and running, most won't need date libraries any more!
@neontuts5637
@neontuts5637 Жыл бұрын
@@CodinginPublic Yes, thank you.
@hardwired89
@hardwired89 Жыл бұрын
@r-i-ch
@r-i-ch Жыл бұрын
Neat. Knew about this, but not the alternate calendars.
@CodinginPublic
@CodinginPublic Жыл бұрын
Me neither until I started looking into it!
@thedeveloper9896
@thedeveloper9896 Жыл бұрын
First again, pog!
@CodinginPublic
@CodinginPublic Жыл бұрын
🙌
@DTUSEM
@DTUSEM Жыл бұрын
I think we can use narrow weekday in calendar
@DTUSEM
@DTUSEM Жыл бұрын
Interesting topic. Suggestion - You can make a series on different APIs weekly.
@CodinginPublic
@CodinginPublic Жыл бұрын
Since I just make one major video a week, I’ll probably mix it up more, but there are so many browser APIs that remove the need for libraries people still use. I’d like to keep going on these types of videos :)
@DTUSEM
@DTUSEM Жыл бұрын
@@CodinginPublic okay
@MuhammadAdnan2.0
@MuhammadAdnan2.0 Жыл бұрын
Great bro 👌
@CodinginPublic
@CodinginPublic Жыл бұрын
Glad you enjoyed it!
@MuhammadAdnan2.0
@MuhammadAdnan2.0 Жыл бұрын
@@CodinginPublic React too...
@CodinginPublic
@CodinginPublic Жыл бұрын
🙌
@franx1c0
@franx1c0 7 ай бұрын
Thanks for the video, I always struggle with JS dates :D do you have any video about adding/removing days? or for that you recommend a library?
@CodinginPublic
@CodinginPublic 7 ай бұрын
Date fns is good! There’s a new temporal api in js for dealing with dates that can also do that. Glad you enjoyed the video!
@djmtype
@djmtype Жыл бұрын
Have you tried this in Astro with markdown files using SSG? When it builds, it's a day off due to the whole timezone issue. When setting the timezone to UTC, it works, but I'm unsure when building this on Netlify, where the timezone may be different, this will return the right date.
@CodinginPublic
@CodinginPublic Жыл бұрын
You can set the time zone and netlify will respect it. So if you take your date object and do the following… date.toLocaleString("en-US", {timeZone: "America/New_York"}));
@huytranuc7870
@huytranuc7870 Жыл бұрын
Cool. What is your theme and font used in this vid?
@CodinginPublic
@CodinginPublic Жыл бұрын
Glad you enjoyed it. Cascadia Code and Monokai Pro (vid here: kzfaq.info/get/bejne/a9t1h7eJ3bzOaKc.html)
JavaScript Modules Crash Course
48:38
freeCodeCamp.org
Рет қаралды 46 М.
#16 How to use the JS Date object | JavaScript Full Tutorial
15:36
Неприятная Встреча На Мосту - Полярная звезда #shorts
00:59
Полярная звезда - Kuzey Yıldızı
Рет қаралды 7 МЛН
Sigma Girl Past #funny #sigma #viral
00:20
CRAZY GREAPA
Рет қаралды 33 МЛН
Formatting lists and numbers in JavaScript with the Intl API
7:55
Coding in Public
Рет қаралды 4,8 М.
Astro Crash Course in 20 Minutes!
22:07
Coding in Public
Рет қаралды 53 М.
شرح عمل Notifications في React باستخدام Toastify
5:31
Keep Coding بالعربي
Рет қаралды 357
Do you know the difference between target vs. currentTarget?
8:25
Coding in Public
Рет қаралды 5 М.
JavaScript Date and Time Tutorial
33:55
Get __it Done!
Рет қаралды 2,6 М.
(FINALLY!) Email for Developers
28:19
Coding in Public
Рет қаралды 105 М.
Formatting Is So Easy With The Intl JavaScript API
10:21
Web Dev Simplified
Рет қаралды 41 М.
УДИВИЛА МЛАДШУЮ СЕСТРУ
0:50
Li ALINA
Рет қаралды 3,2 МЛН
Про арбузик 🍉 #рыбакит #простыерисунки
0:16
Заставил себя уважать!
0:52
МИНУС БАЛЛ
Рет қаралды 1,7 МЛН
Тот кто не коснется воды - получит приз
0:37