How to Format Dates with Vanilla JavaScript

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

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!
@DTUSEM
@DTUSEM Жыл бұрын
I think we can use narrow weekday in calendar
@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!
@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
@thedeveloper9896
@thedeveloper9896 Жыл бұрын
First again, pog!
@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"}));
@MuhammadAdnan2.0
@MuhammadAdnan2.0 Жыл бұрын
Great bro 👌
@CodinginPublic
@CodinginPublic Жыл бұрын
Glad you enjoyed it!
@MuhammadAdnan2.0
@MuhammadAdnan2.0 Жыл бұрын
@@CodinginPublic React too...
@CodinginPublic
@CodinginPublic Жыл бұрын
🙌
@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)
#16 How to use the JS Date object | JavaScript Full Tutorial
15:36
孩子多的烦恼?#火影忍者 #家庭 #佐助
00:31
火影忍者一家
Рет қаралды 40 МЛН
Final muy increíble 😱
00:46
Juan De Dios Pantoja 2
Рет қаралды 45 МЛН
LOVE LETTER - POPPY PLAYTIME CHAPTER 3 | GH'S ANIMATION
00:15
Became invisible for one day!  #funny #wednesday #memes
00:25
Watch Me
Рет қаралды 32 МЛН
Formatting lists and numbers in JavaScript with the Intl API
7:55
Coding in Public
Рет қаралды 4,8 М.
How To Create Tooltips with HTML & CSS Only (no JavaScript needed)
9:09
Vladyslav Dihtiarenko
Рет қаралды 222
React Email First Look
11:21
Coding in Public
Рет қаралды 83 М.
JavaScript Date Object and Time Zones | Fixing an "off by 1 day" bug
16:32
Maker At Play Coding
Рет қаралды 23 М.
Изучим методы функций call, apply, bind в JavaScript
33:07
Елена Литвинова — Искусство Веб-разработки 🛸
Рет қаралды 9 М.
Intl API and Localizing Date and Time | Intl API | JavaScript
13:19
Using the History API - JavaScript Tutorial
16:40
dcode
Рет қаралды 31 М.
Building a React Card Component with TypeScript
51:47
Coding in Public
Рет қаралды 9 М.
Which water gun won??
0:30
toys AS
Рет қаралды 76 МЛН
I chose the biggest glass 😂👻
0:19
Ben Meryem
Рет қаралды 4,2 МЛН
#狼途新品lt75机械键盘 #funny #comedy #memes #baby #icecream
0:15
Doesn't let others play
0:15
V.A. show / Магика
Рет қаралды 25 МЛН