12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- function changeTime(cellValue) {
- var arr = cellValue.split('T')
- var d = arr[0]
- var darr = d.split('-')
- var t = arr[1]
- var tarr = t.split('.000')
- var marr = tarr[0].split(':')
- var dd = parseInt(darr[0]) + '/' + parseInt(darr[1]) + '/' + parseInt(darr[2]) + ' ' + parseInt(marr[0]) + ':' + parseInt(marr[1]) + ':' + parseInt(marr[2])
- return this.formatDateTime(dd)
- }
- function formatDateTime(date) {
- var time = new Date(Date.parse(date))
- time.setTime(time.setHours(time.getHours() + 8))
- var Y = time.getFullYear() + '-'
- var M = this.addZero(time.getMonth() + 1) + '-'
- var D = this.addZero(time.getDate()) + ' '
- var h = this.addZero(time.getHours()) + ':'
- var m = this.addZero(time.getMinutes()) + ':'
- var s = this.addZero(time.getSeconds())
- return Y + M + D + h + m + s
- }
- /**
- * 通过时间戳获取当前时间
- * @returns
- */
- function getNowDate(timestamp) {
- var nowDate = new Date(timestamp);
- // var year = nowDate.getFullYear(); //获取当前年
- // var mon = nowDate.getMonth() + 1; //获取当前月
- // var date = nowDate.getDate(); //获取当前日
- // var hours = nowDate.getHours(); //获取当前小时
- // var minutes = nowDate.getMinutes(); //获取当前分钟
- // var seconds = nowDate.getSeconds(); //获取当前秒
- // var now = year + "-" + mon + "-" + date + " " + hours + ":" + minutes + ":" + seconds;
- // return now;
- return CstTimeToNomalTime(nowDate)
- }
- function addZero(num) {
- return num < 10 ? '0' + num : num
- }
- function CstTimeToNomalTime(time) {
- return `${time.getFullYear()}-${time.getMonth() + 1 >= 10 ? (time.getMonth() + 1) : '0' + (time.getMonth() + 1)}-${time.getDate() >= 10 ? time.getDate() : '0' + time.getDate()} ${time.getHours() >= 10 ? time.getHours() : '0' + time.getHours()}:${time.getMinutes() >= 10 ? time.getMinutes() : '0' + time.getMinutes()}:${time.getSeconds() >= 10 ? time.getSeconds() : '0' + time.getSeconds()}`;
- }
|