2017-01-30 31 views
0

Ich nehme publishedAt Datum, aber ich muss Datumstyp ändern. Jetzt , 2017-01-19T14: 02: 39.000Z aber ich möchte diese Art, 19-01-2017, meine Codes,Take published Datum mit youtube api v3

$.get(
 
\t "https://www.googleapis.com/youtube/v3/playlistItems",{ 
 
\t \t part : 'snippet', 
 
\t \t maxResults : 20, 
 
\t \t playlistId : pid, 
 
\t \t key : 'AIzaSyBZvGyNmLVPDLPcz_clh8tGxl0_1DRNFFE'}, 
 
\t \t function(data) { 
 
\t \t \t var output; 
 
\t \t \t $.each(data.items, function(i,item) { 
 
\t \t \t \t console.log(item); 
 
\t \t \t \t videoTitle = item.snippet.title; 
 
\t \t \t \t videoId = item.snippet.resourceId.videoId; 
 
\t \t \t \t videoDate = item.snippet.publishedAt; 
 
\t \t \t \t videoGorsel = item.snippet.thumbnails.default.url; 
 
\t \t \t \t height = item.snippet.thumbnails.default.height; 
 
\t \t \t \t width = item.snippet.thumbnails.default.width;

Antwort

0

Angenommen, Sie haben die Antwort analysiert und Erhalten Sie den Datumswert 2017-01-19T14: 02: 39.000Z, hier ist, wie es geht. Mit dem Date methods from W3 Schools:

var isODate = new Date("2017-01-19T14:02:39.000Z"); 

var shortDate = new Date(isODate); 
var day = shortDate.getDate(); 
var month = shortDate.getMonth() + 1; 
var year = shortDate.getFullYear(); 

var stringdate = day+"-"+month+"-"+year; 
console.log(stringdate); 

OUTPUT: 19-1-2017