Sharepoint - Changing date format using javascript

SharePoint adds a String.format function
so you can use:

String.format('{0:yyyy}-{0:MM}-{0:dd}',new Date('2015-10-30T05:00:00Z'));

Note: String.format is defined in msajaxbundle.js, loaded even before most of the JavaScript files so safe to use without SOD requirements or anything.
It was modelled after the C# and VB implementations, so the MSDN documentation applies
(for the major part; it does not do the alignment stuff as that makes no sense in HTML)

String.format("{0:i}",new Date());  outputs: Wed Oct 07 2015 20:39:54 GMT+0200 (W. Europe Daylight Time)
String.format("{0:F}",new Date());  outputs: Wednesday, 07 October 2015 20:39:54
String.format("{0:f}",new Date());  outputs: Wednesday, 07 October 2015 20:39
String.format("{0:D}",new Date());  outputs: Wednesday, 07 October 2015
String.format("{0:s}",new Date());  outputs: 2015-10-07T20:39:54
String.format("{0:d}",new Date());  outputs: 10/07/2015
String.format("{0:dd}",new Date());  outputs: 07
String.format("{0:ddd}",new Date());  outputs: Wed
String.format("{0:dddd}",new Date());  outputs: Wednesday
String.format("{0:m}",new Date());  outputs: October 07
String.format("{0:M}",new Date());  outputs: October 07
String.format("{0:MM}",new Date());  outputs: 10
String.format("{0:MMM}",new Date());  outputs: Oct
String.format("{0:MMMM}",new Date());  outputs: October
String.format("{0:Y}",new Date());  outputs: 2015 October
String.format("{0:y}",new Date());  outputs: 2015 October
String.format("{0:yy}",new Date());  outputs: 15
String.format("{0:yyyy}",new Date());  outputs: 2015
String.format("{0:gg}",new Date());  outputs: A.D.
String.format("{0:T}",new Date());  outputs: 20:39:54
String.format("{0:t}",new Date());  outputs: 20:39
String.format("{0:HH}",new Date());  outputs: 20
String.format("{0:mm}",new Date());  outputs: 39
String.format("{0:ss}",new Date());  outputs: 54

It does more then just Dates:

MSDN String.format() Documentation

J5 iJS string format top20 iDate


I would strongly suggest using the MomentJS library for all date/time work client side. Writing JavaScript functions to handle this stuff is so 2000s at this point. I load MomentJS into every client side project I do these days.

http://momentjs.com


Store the value retrieved from REST call in a variable and use JavaScript slice method to get the date part. Example:

var x = "2015-10-30T05:00:00Z";
var y = x.slice(0,10);
alert(y);