function getDateFormat(str) {
return str.split('').join('-')
.replace("年", "yyyy")
.replace("月", "MM")
.replace("日", "dd")
.replace("时", "HH")
.replace("分", "mm")
.replace("秒", "ss").replace(/dd-/,'dd ').replace(/HH-/,"HH:").replace(/mm-/,"mm:");
}
console.log(getDateFormat('年月日'))
console.log(getDateFormat('年月'))
console.log(getDateFormat('年'))
console.log(getDateFormat('年月日时分秒'))
console.log(getDateFormat('年月日时分'))
console.log(getDateFormat('年月日时'))
console.log(getDateFormat('时分秒'))
console.log(getDateFormat('时分'))