How to change the number format of Data ex: from YYYY/MM/DD to DD/MM/YYYY

Forums How to solve How to change the number format of Data ex: from YYYY/MM/DD to DD/MM/YYYY

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #10437
    shefariza
    Participant

    To achieve the foramat data we want, we first need to install the pacage moment. js
    Here is how you can install it through CDN and installation.

    _______________________CDN__________________________
    <script src=”https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.3/moment.min.js”&gt; </script>
    _____________________instaltion_________________________
    npm install moment –save # npm
    yarn add moment # Yarn
    Install-Package Moment.js # NuGet
    spm install moment –save # spm
    meteor add momentjs:moment # meteor
    bower install moment –save # bower (deprecated)

    After insaltation, we need to use it, and we do this by importing it.
    import Moment from “moment”;

    ____________________ What it does________________
    It will just format the date from YYYY/MM/DD to DD/MM/YYYY.

    _________________ How to use it___________________
    Moment(date).format(“DD/MM/YYYY HH:mm:ss”)
    In the date, we should use the variable that contains the value of the data, and in the format, it will contain a string in the format that you will need to format your data.

    _____________ How do I use it________________
    this.records.forEach(rec=>{

    The date here was May 21, 2024.
    Moment(rec.doc_date). format(“DD/MM/YYYY HH:mm:ss”),

    The date here is May 21, 2024.

    }

     

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.