dateTool.js 487 Bytes
'use strict'
import moment from 'moment';

export function getLastDay() {
    return moment().subtract(1, 'days').format('YYYY-M-D');
}

export function add0(m){return m<10?'0'+m:m }
export function format(shijianchuo)
{
var time = new Date(shijianchuo);
var y = time.getFullYear();
var m = time.getMonth()+1;
var d = time.getDate();
var h = time.getHours();
var mm = time.getMinutes();
var s = time.getSeconds();
return y+'-'+add0(m)+'-'+add0(d)+' '+add0(h)+':'+add0(mm)+':'+add0(s);
}