How to Format Dates with Vanilla JavaScript

Поделиться
HTML-код
  • Опубликовано: 11 янв 2025

Комментарии • 24

  • @JosephCodette
    @JosephCodette 2 года назад +2

    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  2 года назад +1

      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 2 года назад +1

    Thanks for sharing Chris 🙏. Now no need of using packages to format dates in JavaScript. And it is easy to implement.

    • @CodinginPublic
      @CodinginPublic  2 года назад +1

      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 2 года назад

      @@CodinginPublic Yes, thank you.

  • @DTUSEM
    @DTUSEM 2 года назад +1

    I think we can use narrow weekday in calendar

  • @r-i-ch
    @r-i-ch 2 года назад

    Neat. Knew about this, but not the alternate calendars.

    • @CodinginPublic
      @CodinginPublic  2 года назад

      Me neither until I started looking into it!

  • @franx1c0
    @franx1c0 Год назад

    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  Год назад +1

      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 2 года назад +2

    Interesting topic.
    Suggestion - You can make a series on different APIs weekly.

    • @CodinginPublic
      @CodinginPublic  2 года назад +1

      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 2 года назад +1

      @@CodinginPublic okay

  • @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  Год назад +1

      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"}));

  • @hardwired66
    @hardwired66 2 года назад

  • @MuhammadAdnan2.0
    @MuhammadAdnan2.0 2 года назад

    Great bro 👌

  • @huytranuc7870
    @huytranuc7870 2 года назад

    Cool. What is your theme and font used in this vid?

    • @CodinginPublic
      @CodinginPublic  2 года назад

      Glad you enjoyed it. Cascadia Code and Monokai Pro (vid here: ruclips.net/video/5uETTXxVj8s/видео.html)

  • @thedeveloper9896
    @thedeveloper9896 2 года назад +1

    First again, pog!