时间格式化

this.fsTimeValue = new Date().toLocaleString("zh-CN", {
					year: 'numeric',
					month: 'numeric',
					day: 'numeric',
					hour: 'numeric',
					minute: 'numeric',
					second: 'numeric',
					hour12: false
				});

var then = new Date(2019, 2 ,2); //2019年3月2日
var later = new Date(2019, 2 ,2, 17, 22, 24); //2019年3月2日5:22:24pm
var now = new Date(); //当前日期和时间
var elapsed = now - then; //日期减法:计算时间间隔的毫秒数
later.getFullYear() //=>2019
later.getMonth() //=>2:从0开始计数的月份
later.getDate() //=>2:从1开始计数的天数
later.getDay() //=>5:获取星期几,0代表星期日,1到6分别对应星期一到星期六
later.getHours() //=>17:获取小时数
later.getMinutes() //=>22:获取分钟数
later.getSeconds() //=>24:获取秒数
getTime(){
        var now = new Date();
        var year = now.getFullYear();
        var m = now.getMonth() + 1;
        var month = m < 10 ? '0' + m : m;
        var day = now.getDate() < 10 ? '0' + now.getDate() : now.getDate();
        var hour = now.getHours() < 10 ? '0' + now.getHours() : now.getHours();

        this.dateTime = year + '-' + month + '-' + day + ' ' + hour + ':' + '00' ;
      },

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值