getDate.js
440 字节
/**
* @param {String} str (y-m-d h:i:s) y:年 m:月 d:日 h:时 i:分 s:秒
*/
export function dateTimeStr(str){
var date = new Date()
year = date.getFullYear() //年
month = date.getMonth() + 1, //月
day = date.getDate() //日
if(str.indexOf('y') != -1){
str = str.replace('y', year)
}
if(str.indexOf('m') != -1){
str = str.replace('m', month)
}
if(str.indexOf('d') != -1){
str = str.replace('d', day)
}
return str;
}