Search code examples
jquerydatespservices

JQuery and SPServices Date Format


So I found some code where a guy is using JQuery function for formatting dates in SharePoint with SPServices. I am currently doing the same method but can't get it to work.

I would like to format the date from yyyy-mm-dd hh:mm:ss to MMM-dd I'm not sure what I'm doing wrong but I can't get it to work properly in my example on codepen.

Any help would be great http://codepen.io/deaconf19/pen/xGNgoJ?editors=101


Solution

  • Add a reference to moment.js file. This can be downloaded from here. And in java script use the format you want to display:

    var startDate = "2015-08-18 13:14:15";
    alert(moment(startDate).format('MMM-DD'));
    <script src="http://momentjs.com/downloads/moment.js"></script>