Skip to content

Commit

Permalink
[feature]{utils}: 加入一处时间函数获取 2019-01-01
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo committed May 26, 2019
1 parent cffdf4e commit 09dba3e
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,37 @@ export function timestampToTime(timestamp) {
console.log(Y + M + D + h + m + s);
return Y + M + D + h + m + s;
}


/**
* 获取当前日期 2019年01月01日
*/
export function DateTimeNow() {
const date = new Date();
const Y = `${date.getFullYear()}年`;
const M = `${date.getMonth() + 1 < 10 ? `0${date.getMonth() + 1}` : date.getMonth() + 1}月`;
const D = `${date.getDate()}日`;
return Y + M + D;
}

/**
* 获取当前日期 2019-01-11
*/
export function DateTimeNowSplit() {
const date = new Date();
const Y = `${date.getFullYear()}-`;
const M = `${date.getMonth() + 1 < 10 ? `0${date.getMonth() + 1}` : date.getMonth() + 1}-`;
const D = `${date.getDate()}`;
return Y + M + D;
}

/**
* yyyy-MM-dd HH:mm:ss 转 2019年1月1日
*/
export function DateTimeFormat(time) {
let date = time.split(' ')[0];
date = date.replace('-', '年');
date = date.replace('-', '月');
date += '日';
return date;
}

0 comments on commit 09dba3e

Please sign in to comment.