即格式化中国标准时间为2020-09-10形式,中间的分隔符可以自行修改
//js不自带foramt函数了之后需要自行下载并引用
import { format } from "@/commonjs/date.format.js";
var time1 = new Date(2020, 1, 1)
//年月日
time1.format("y-m-d")
//时分秒
time1.format("h:m:s")
//其他写法
(new Date()).Format("yyyy-MM-dd hh:mm:ss.S") // 2020-07-02 08:09:04.423
(new Date()).Format("yyyy-M-d h:m:s.S") // 2020-7-2 8:9:4.18
在element-ui 的时间选择器中回显时间需要加value-format="hh:mm:ss"
<el-time-picker
v-model="retentStarTime"
:picker-options="{
selectableRange: '00:00:00 - 23:59:59'
}"
value-format="hh:mm:ss"
placeholder="点击选择任意时间点"
></el-time-picker>