As you mentioned in comments that you want to format date to DD-MM-YYYY
, you dont require moment js to be loaded. SharePoint itself provides the necessary functions to format date as per your requirement.
Danny Engelman, one of the community's top contributors has provided an excellent answer at the below link:
Changing date format using javascript
So, for your case, you can use it as below:
var LifeCycleStart = String.format('{0:dd}-{0:MM}-{0:yyyy}',new Date(item.DeviceAvailableFrom))
So your overall code would be as below:
call.done(function (data,textStatus, jqXHR){
$.each(data.d.results, function(index, item) {
var tempID = item.Id;
var tempTitle = item.Title;
var LifeCycleStart = String.format('{0:dd}-{0:MM}-{0:yyyy}',new Date(item.DeviceAvailableFrom));
var LifeCycleStatus = item.LifeCycleStatusValue;
var DeviceOverView = item.Description;
txtTitle = "<p>" + LifeCycleStart + "</p><p>" + LifeCycleStatus + "</p>";
txtOverview = "<p>" + DeviceOverView + "</p>";
});
$('#devicedetails').append($(txtTitle));
$('#deviceoverview').append($(txtOverview));
});
Based on your comments, can you try below code. I am using the replace
method to change the string format:
call.done(function (data,textStatus, jqXHR){
$.each(data.d.results, function(index, item) {
var tempID = item.Id;
var tempTitle = item.Title;
var LifeCycleStart = item.DeviceAvailableFrom.replace(/\//g, '-');
var LifeCycleStatus = item.LifeCycleStatusValue;
var DeviceOverView = item.Description;
txtTitle = "<p>" + LifeCycleStart + "</p><p>" + LifeCycleStatus + "</p>";
txtOverview = "<p>" + DeviceOverView + "</p>";
});
$('#devicedetails').append($(txtTitle));
$('#deviceoverview').append($(txtOverview));
});