前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >cssjshtml DateTimePicker时间慢8小时

cssjshtml DateTimePicker时间慢8小时

作者头像
葫芦
发布2019-04-17 16:32:29
7900
发布2019-04-17 16:32:29
举报
文章被收录于专栏:葫芦

问题:

使用element-ui  DateTimePicker组件 直接将值传给后台发现选择的时间比正常时间慢8小时。

前台console.log显示:  

[Thu Mar 07 2019 12:00:00 GMT+0800 (中国标准时间), Mon Apr 15 2019 00:00:00 GMT+0800 (中国标准时间), __ob__: Observer]

与所选时间一致,但是到了后台却慢了8小时:

[u'2019-03-07T04:00:00.000Z', u'2019-04-14T16:00:00.000Z']

解决方法:

前台:

代码语言:javascript
复制
let start_time = ''
let end_time = ''
if (this.times.length === 2) {
start_time = this.times[0].getFullYear() + '-' + (this.times[0].getMonth() + 1) + '-' + this.times[0].getDate() + ' ' + this.times[0].getHours() + ':' + this.times[0].getMinutes() + ':' + this.times[0].getSeconds();
end_time = this.times[1].getFullYear() + '-' + (this.times[1].getMonth() + 1) + '-' + this.times[1].getDate() + ' ' + this.times[1].getHours() + ':' + this.times[1].getMinutes() + ':' + this.times[1].getSeconds();

        }

后台:

代码语言:javascript
复制
if start_time!='':
    start_time=datetime.strftime(datetime.strptime(start_time, '%Y-%m-%d %H:%M:%S'), '%Y-%m-%d %H:%M:%S')
    end_time=datetime.strftime(datetime.strptime(end_time, '%Y-%m-%d %H:%M:%S'), '%Y-%m-%d %H:%M:%S')

后台输出:

代码语言:javascript
复制
2019-03-07 12:00:00 2019-04-15 00:00:00

不但 时间对了,顺便还进行了所需格式的格式化

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019/03/22 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 后台:
  • 后台输出:
  • 不但 时间对了,顺便还进行了所需格式的格式化
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档