How to Format Dates with Vanilla JavaScript

  Рет қаралды 5,998

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.
@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
@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!
@DTUSEM
@DTUSEM Жыл бұрын
I think we can use narrow weekday in calendar
@franx1c0
@franx1c0 6 ай бұрын
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 6 ай бұрын
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!
@MuhammadAdnan2.0
@MuhammadAdnan2.0 Жыл бұрын
Great bro 👌
@CodinginPublic
@CodinginPublic Жыл бұрын
Glad you enjoyed it!
@MuhammadAdnan2.0
@MuhammadAdnan2.0 Жыл бұрын
@@CodinginPublic React too...
@CodinginPublic
@CodinginPublic Жыл бұрын
🙌
@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: kzbin.info/www/bejne/a6aohYeOrbudbtU)
@thedeveloper9896
@thedeveloper9896 Жыл бұрын
First again, pog!
@CodinginPublic
@CodinginPublic Жыл бұрын
🙌
#16 How to use the JS Date object | JavaScript Full Tutorial
15:36
Using the History API - JavaScript Tutorial
16:40
dcode
Рет қаралды 31 М.
Be kind🤝
00:22
ISSEI / いっせい
Рет қаралды 20 МЛН
Заметили?
00:11
Double Bubble
Рет қаралды 2,5 МЛН
Sprinting with More and More Money
00:29
MrBeast
Рет қаралды 65 МЛН
Изучим методы функций call, apply, bind в JavaScript
33:07
Елена Литвинова — Искусство Веб-разработки 🛸
Рет қаралды 9 М.
The Problem with Time & Timezones - Computerphile
10:13
Computerphile
Рет қаралды 4 МЛН
Working with Dates in JS | new Date(), getDate(), getFullYear(), toISOString() | Lecture # 21
14:29
Aptech Learning Garden - Site - Orangi - Latifabad
Рет қаралды 423
JavaScript Error Handling: 5 Things You Aren’t Thinking About!
14:42
Vanilla JavaScript Challenge (DOM manipulation)
30:25
Coding in Public
Рет қаралды 4,4 М.
You're using Javascript Promises The wrong way
9:57
CoderOne
Рет қаралды 56 М.
MVVM vs. MVI - Understand the Difference Once and for All
18:40
Philipp Lackner
Рет қаралды 27 М.
Subtle, yet Beautiful Scroll Animations
5:04
Beyond Fireship
Рет қаралды 1,6 МЛН
Forging a cool BBQ Fork
1:00
Rust Legion
Рет қаралды 14 МЛН
😨 СФОТКАЛА незнакомца и собрала на @mozabrick
0:46
Настя, это где?
Рет қаралды 12 МЛН
New Gadgets! Bycycle 4.0 🚲 #shorts
0:14
BongBee Family
Рет қаралды 9 МЛН
Why You Should Always Help Others ❤️
0:40
Alan Chikin Chow
Рет қаралды 3,1 МЛН
CORRUGATED CARDBOARD KENKENPA!#shorts
0:19
HAYATAKU はやたく
Рет қаралды 11 МЛН