|
@@ -58,3 +58,24 @@ export function checkStr (currentStr, strList) {
|
|
|
let index = list.findIndex(item => item === currentStr)
|
|
|
return index > -1
|
|
|
}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 日期处理:字符串转日期
|
|
|
+ */
|
|
|
+export function strToDate (str) {
|
|
|
+ if (!str) return null
|
|
|
+ return dateToString(Date.parse(str))
|
|
|
+}
|
|
|
+export function dateToString (date) {
|
|
|
+ let date1 = new Date(date)
|
|
|
+ const year = date1.getFullYear() + ''
|
|
|
+ let month = (date1.getMonth() + 1) + ''
|
|
|
+ let day = (date1.getDate()) + ''
|
|
|
+ if (month.length === 1) {
|
|
|
+ month = '0' + month
|
|
|
+ }
|
|
|
+ if (day.length === 1) {
|
|
|
+ day = '0' + day
|
|
|
+ }
|
|
|
+ return year + '-' + month + '-' + day
|
|
|
+}
|