开发者

Reverse the display of a date using jQuery

开发者 https://www.devze.com 2023-04-07 10:44 出处:网络
I have a date returned in this format YYYY-MM-DD, e.g. 2011-04-29.Using jQuery how can I make the dat开发者_StackOverflowe 29-04-2011?You can use .reverse()

I have a date returned in this format YYYY-MM-DD, e.g. 2011-04-29. Using jQuery how can I make the dat开发者_StackOverflowe 29-04-2011?


You can use .reverse()

var pieces = '2011-07-27'.split('-');
pieces.reverse();
var reversed = pieces.join('-');


var parts = '2011-07-27'.split(/-/);
parts.reverse();
alert(parts.join('-'));
0

精彩评论

暂无评论...
验证码 换一张
取 消