码迷,mamicode.com
首页 > Web开发 > 详细

js 数据格式化

时间:2017-08-24 12:28:42      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:ret   str   log   orm   atp   code   格式化   class   ice   

//金额增加千分号formatPrice(123456.78) = 123,456.78
function formatPrice(val) {
    var parts = val.toString().split(".");
    parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
    return parts.join(".");

}

//将/Date(13925635263)/转换成Date
function formatDate(val) {
    return new Date(parseInt(val.replace(/\D/igm, "")));
}

 

js 数据格式化

标签:ret   str   log   orm   atp   code   格式化   class   ice   

原文地址:http://www.cnblogs.com/xbzhu/p/7422268.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!