時間轉換爲時間戳

methods: {
            //提交表單關閉彈窗
            handleSubmit(formName) {
                this.$refs[formName].validate((valid) => {
                    if (!valid) {
                        return;
                    }
                    this.form.payment_time = Date.parse(new Date(this.form.payment_time)) / 1000;//轉換爲秒
                    this.form.refund_time = Date.parse(new Date(this.form.refund_time)) / 1000;
                    let data = {
                        id: this.form.id || '',
                        ...this.form,
                    };
                    this.$post('/goods/bidding/payment/update', data, (res) => {
                        if (!res.status) {
                            this.$message.error(res.message || '操做失敗!');
                            return;
                        }
                        this.$message.success('操做成功!');
                        this.handleClearData();
                        this.$emit('paipaymentFormdialogClose')
                    });
                })
            },
            handleClearData() {
                this.$refs['form'].resetFields();
            },
        }

var date = new Date('2014-04-23 18:55:49:123');post

    // 有三種方式獲取this

    var time1 = date.getTime();code

    var time2 = date.valueOf();orm

    var time3 = Date.parse(date);ip

    console.log(time1);//1398250549123get

    console.log(time2);//1398250549123it

    console.log(time3);//1398250549000console

 

第1、第二種:會精確到毫秒form

  第三種:只能精確到秒,毫秒用000替代表單

相關文章
相關標籤/搜索