Trần Trung Trần Trung - 1 year ago 146
Ajax Question

Get only date without time from REST query on Sharepoint 2013

I have a date column on a Custom List. The format of that column can be set on Edit Column Page and it displays only date as expected on my Custom List page. But then I want to create a REST query by using ajax and display it on console log for debugging. The date is display as follow:


Are there any ways to make it return only mm/dd/yyyy?

Answer Source

I don't know that api but you can easly parse date with plain JavaScript.

var date_tz = "2016-08-08T17:00:00Z";
f_z =  function(v) { if(parseInt(v) < 10) return "0"+v; return $v;}; // filling with 0 if needed

var d = new Date(date_tz);
d = f_z(d.getDate()) + '/' + f_z((d.getMonth()+1)) + '/' + d.getFullYear();

alert(d); // "08/08/2016"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download