How to Display Dates and Times in JavaScript - Beginner's Tutorial

Поділитися
Вставка
  • Опубліковано 12 вер 2024
  • In today's video I'll be showing you how to display/format dates and times in JavaScript. I'll be showing two examples: plain JavaScript and using a library like Day.js
    Day.js Library:
    day.js.org/doc...
    For your reference, check this out:
    www.w3schools....
    💜 Join my Discord Server:
    / discord
    Support me on Patreon:
    / dcode
    Follow me on Twitter:
    @dcodeyt
    If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!
    #dcode

КОМЕНТАРІ • 26

  • @yudhweersingh
    @yudhweersingh 3 роки тому

    A lot of learning for me, Thanks for making such a great video. And your English accent is very clear easy to understand.

  • @hunnidbands100
    @hunnidbands100 3 роки тому +2

    thank you for padstart didnt know bout this method

  • @woestyn202
    @woestyn202 9 місяців тому

    thank you so much for this video. "dcode" you Rock man!

  • @RaviTeja-ec7mf
    @RaviTeja-ec7mf 3 роки тому +2

    I learned something new in this video
    Great job 👍

  • @isaacrivera5452
    @isaacrivera5452 2 роки тому

    thank you you explained everything, some other video does the code without even showing how and why it does what.

  • @jamesmassa1999
    @jamesmassa1999 3 роки тому

    Dom liked this vid! Your coding is intuitive. : ) : ) Thank you for your time and effort!

  • @widespectrumcreators4691
    @widespectrumcreators4691 8 місяців тому

    You rock man! 👍👍🤩🤩

  • @jacob-w
    @jacob-w 3 роки тому +1

    Vanilla Javascript has Intl.DateTimeFormat() functions, so you don't usually need to build simple or standard data formats by hand or use external libraries. Check MDN for documentation. Just Google: "Intl.DateTimeFormat" and you'll get the docs. :) Browser compatibility is no issue.

    • @dcode-software
      @dcode-software  3 роки тому +2

      Thanks, yeah you can use that method if it works for you but it doesn't let you pass in a mask to get custom formatting.

    • @jacob-w
      @jacob-w 3 роки тому

      @@dcode-software You can always use Intl.DateTimeFormat.prototype.formatToParts() and get an array that holds every single part of a datetime, if you want something non-standard and/or custom formats. It's locale aware, so you don't even have to translate your months and days! :-)
      But sure, you cant't pass a format to that directly, but that's almost the point oft Intl.DateTimeFormat - you usually don't have to and you don't have to know how dates are formatted internationally.
      Anyway I do like your videos and this is not a criticizm. Just a suggestion that there is a "standard way" of doing things too.
      As a non-native english speaker those Intl functions are close to my heart. :-D Intl.NumberFormat() and Intl.RelativeTimeFormat() are worth checking out too.

  • @tuannguyenanh3178
    @tuannguyenanh3178 3 роки тому

    Thanks a lot - just what I am looking for.

  • @mahmudulhasan6355
    @mahmudulhasan6355 2 роки тому

    nice one!!!! thanks a lot!!!!

  • @mrcash1309
    @mrcash1309 3 роки тому

    This is really nice. Thank you :)

  • @noctxrnyl8240
    @noctxrnyl8240 Рік тому

    v informative

  • @mounir101
    @mounir101 3 роки тому

    Pretty awesome!

  • @romuloalves9349
    @romuloalves9349 3 роки тому +1

    Ótimo vídeo parabéns 👍.

  • @sudeepkumar8844
    @sudeepkumar8844 3 роки тому

    Sir please make tutorial on web push notifications complete.

  • @dbd868
    @dbd868 3 роки тому

    how to add say, "5 days 3 hours 2 minutes to that code so that i could get the time to finished a certain production....help me out...thanks for this its really great....

  • @israelochoab3113
    @israelochoab3113 3 роки тому

    And what about Intl.DateTimeFormat?

  • @rangabharath4253
    @rangabharath4253 3 роки тому

    awesome

  • @Knorway56
    @Knorway56 3 роки тому

    👍

  • @mallusrgreat
    @mallusrgreat 3 роки тому

    Why do you have low views