安卓苹果获取时间戳转成本地时间

for(var i=0; i<ret.result.length; i++) {
                var f_time = getLocaleTimeByUnixTime(ret.result[i].receivedTime);
                var f_time_start = f_time.indexOf(':')-2;
                var f_time_end = f_time.indexOf(':')+3;
                var t_time_local = f_time.substring(f_time_start,f_time_end);
                ret.result[i]["receviedLocaleTime"] = t_time_local;
            }
function getLocaleTimeByUnixTime(unix) {
    var now = new Date(parseInt(unix) * 1000);
    return now.toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
}

 

for(var i=0; i<ret.result.length; i++) {
                if(api.systemType == 'ios') {
                    ret.result[i]["receviedLocaleTime"] = currentDate.toLocaleTimeString().substring(5,10);
                } else {
                    ret.result[i]["receviedLocaleTime"] = currentDate.toLocaleTimeString().substring(0,5);
                }
            }

 

posted @ 2015-08-03 16:17  东师理想--周枫  阅读(388)  评论(0编辑  收藏  举报