locked
Convert Long Date to Standard date using JSOM RRS feed

  • Question

  • Dear All,

    I had column "End Date" in my SharePoint list and when I am reading the value I am getting Long date information as "Mon Apr 30 10:30:00 UTC+0530 2018".

    Can any one let me know how can I convert to standard date using JSOM.

    Friday, March 16, 2018 12:10 PM

Answers

  • Dear ,

    Thanks for your kind support ,  I am back to office after my OPT. 
    I don't now y I am facing new issues with SharePoint On-Prem , Used moment.js . And it got solved.

    var currentDate = new Date("Mon Apr 30 10:30:00 UTC+0530 2018");
                alert(moment(currentDate).format('DD:MM:YYYY'));

    Tuesday, March 27, 2018 4:41 PM

All replies

  • Hi ,

    try this

    <script>
    var currentDate = new Date("Mon Apr 30 10:30:00 UTC+0530 2018");


    currentDate.toLocaleDateString();
    </script>

    Friday, March 16, 2018 2:30 PM
  • Hi SharePoint,

    ASP.NET AJAX (which is a part of SharePoint - MicrosoftAjax.js) extends the JavaScript Date object with a formatting function that closely mimics the DateTime.ToString method

    var selectedDateTime = "Mon Apr 30 10:30:00 UTC+0530 2018";
    var fmtModified = selectedDateTime.format('dd MMM yyyy, hh:ss');

    Have a look on a similar thread

    https://sharepoint.stackexchange.com/questions/73609/format-date-using-javascript-object-model


    Best Regrads, Ahmed Madany MCTS @twitter http://twitter.com/ahmed_madany @Blog http://ahmedmadany.wordpress.com @LinkedIn http://eg.linkedin.com/pub/ahmed-madany/35/80/2b6

    Friday, March 16, 2018 4:29 PM
  • Raghava,

    I opted you suggestion and after the conversation I am getting the below result .Can any please suggest me further

    Monday, April 30, 2018

    Tuesday, March 20, 2018 8:51 AM
  • Hi ,

    What is the date format are you looking for ?

    Tuesday, March 20, 2018 3:51 PM
  • 4/30/2018 : MM:DD/YYYY
    Tuesday, March 20, 2018 6:38 PM
  • try this ..

    <script>
    var currentDate = new Date("Mon Apr 30 10:30:00 UTC+0530 2018");


    currentDate.toLocaleDateString("en-US");
    < /script>

    Tuesday, March 20, 2018 7:08 PM
  • Hi,

    You could format the time as your format strings.

    Just an example.


    Best Regards,

    Lee


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Wednesday, March 21, 2018 12:57 AM
  • Hi,

    I am checking to see how things are going there on this issue. Please let us know if you would like further assistance.

    You can mark the helpful post as answer to help other community members find the helpful information quickly.

    You can also share your own solution here and mark it as answer, so it may help others who has similar requirement.

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Monday, March 26, 2018 7:43 AM
  • Dear ,

    Thanks for your kind support ,  I am back to office after my OPT. 
    I don't now y I am facing new issues with SharePoint On-Prem , Used moment.js . And it got solved.

    var currentDate = new Date("Mon Apr 30 10:30:00 UTC+0530 2018");
                alert(moment(currentDate).format('DD:MM:YYYY'));

    Tuesday, March 27, 2018 4:41 PM