locked
Unable to Execute the Moment.js for date convertion RRS feed

  • Question

  • User-571605279 posted

    Dear All,

    I had written the simple moment.js program where I am willing to convert the date . But I am finding no luck.
    Can any one please let me know what I am missing in below code

    <!DOCTYPE html>
    <html>
    <head>
     <script src="/js/moment.min.js"></script>
    <script src="/js/moment.executor.js"></script>
    <script>
    function myFunction()
    {
    alert("Hello World");
    var strStartDate = 'Mon Apr 30 10:30:00 UTC+0530 2018';
    var MyDate = moment.utc(strStartDate).format('MM/DD/YYYY ');
    alert(MyDate);
    }
    </script>
    </head>
    <body>
      <button onclick="myFunction()">Try it</button>
    </body>
    </html>
    

    Saturday, March 24, 2018 2:36 PM

Answers

  • User-571605279 posted
    <!DOCTYPE html>
    <html>
    <head>
    <script language="javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <script language="javascript" src="https://momentjs.com/downloads/moment.min.js"></script>
    <script>
    function myFunction()
    {
    alert("Hello World");
    var strStartDate = 'Mon Apr 30 10:30:00 UTC+0530 2018';
    var MyDate = moment.utc(strStartDate).format('MM/DD/YYYY ');
    alert(MyDate);
    }
    </script>
    </head>
    <body>
      <button onclick="myFunction()">Try it</button>
    </body>
    </html>
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, March 24, 2018 3:00 PM