开发者

Reverse the display of a date using jQuery

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜