导航栏: 首页 评论列表

日期格式转换 字符串转数字

默认分类 2012-11-29 10:43:50

···· javascript

    var list = [
    '2011-01-07 07:08:25',
    '2011-01-12 18:55:30'
    ];

    function doit(){
        //todo
        var s,d;
        for (i=0,len=list.length; i<len; i++) {
            s = list[i];
            if (s.indexOf('20')<3) {
                d = new Date(Date.parse(s.replace(/-/g,   "/")));
                document.write(d.getTime()/1000);
            }
            else {
                document.write(s); 
            }
            document.write('<br/>'); 

        }
    }


>> 留言评论