首页 > angular中怎么把格式化的日期转化成时间戳

angular中怎么把格式化的日期转化成时间戳

RT,或者用js的原生的方法应该怎么写呢?这个需要自己造轮子吗


估计是要写写

    var dateSplitted = date.split('-'); // date must be in DD-MM-YYYY format
    var formattedDate = dateSplitted[1]+'/'+dateSplitted[0]+'/'+dateSplitted[2];
    var miao=new Date(formattedDate).getTime();

如果有日期对象的话,直接valueOf()...

(new Date)
// Wed May 06 2015 16:01:58 GMT+0800 (CST)

(new Date).valueOf()
// 1430899328358


var date = 'Wed May 06 2015 16:01:58 GMT+0800 (CST)';

date = new Date(date);

date.valueOf()
【热门文章】
【热门文章】