我采取发布日期,但ı需要更改日期类型。现在,2017-01-19T14:02:39.000Z但我想要这种类型, 19-01-2017,我的代码,
$.get(
"https://www.googleapis.com/youtube/v3/playlistItems",{
part : 'snippet',
maxResults : 20,
playlistId : pid,
key : 'AIzaSyBZvGyNmLVPDLPcz_clh8tGxl0_1DRNFFE'},
function(data) {
var output;
$.each(data.items, function(i,item) {
console.log(item);
videoTitle = item.snippet.title;
videoId = item.snippet.resourceId.videoId;
videoDate = item.snippet.publishedAt;
videoGorsel = item.snippet.thumbnails.default.url;
height = item.snippet.thumbnails.default.height;
width = item.snippet.thumbnails.default.width;
假设您已经解析了响应并获得了日期值 2017-01-19T14:02:39.000Z,以下是操作方法。使用 W3 学校的日期方法:
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);
输出:19-1-2017