简体   繁体   English

如何显示SoundCloud曲目的发行年份?

[英]How to display release year of SoundCloud track?

The soundcloud Api mentions 'release_year' but I can't seem to get it to display via a javascript 'append'. soundcloud Api提到“ release_year”,但我似乎无法通过javascript“ append”显示它。 I have tried 'created_at' and this works but displays too much information ie "2012/01/16 09:23:45 +0000" - I only want to display the year that the track was released/uploaded to soundcloud. 我已经尝试过'created_at',但是可以显示太多信息,例如“ 2012/01/16 09:23:45 +0000”-我只想显示曲目发行/上载到soundcloud的年份。

 $('p', this).html(track.created_at); 

The line above is currently working @ http://artpenleystudios.com but I only want the year. 上面的行当前在@ http://artpenleystudios.com上运行,但我只想要年份。

Additional information: I am building a soundcloud audio player based on 'custom soundcloud player' https://github.com/soundcloud/soundcloud-custom-player 附加信息:我正在基于“自定义soundcloud播放器” https://github.com/soundcloud/soundcloud-custom-player构建一个soundcloud音频播放器。

I appreciate any help. 感谢您的帮助。 Thanks 谢谢

如果日期格式始终相同,为什么不这样做:

$('p', this).html(track.created_at.substring(0,4));

You're looking for Date#getUTCFullYear . 您正在寻找Date#getUTCFullYear

var creationDate = new Date(track.created_at);
$('p', this).html(creationDate.getUTCFullYear()); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM