dsgsdg206050 2012-10-22 06:09
浏览 22
已采纳

计算两个时间段之间的差异

Hi i am using third party API to display the feeds in our site, in that i have fields called opentime and closetime in db table. The feed table is being updated for every 20 seconds .Things working fine, now the problem is with opentime and closetime. Its giving 3 Hrs time in the future(it might be their server time) from the current time in my server. Say example, if my server current time is 8:00 AM, at the time feed table is being updated the opentime as 11:00 AM(3 Hrs from now, sometime its varying). We can't do any changes with feed table since the table is updating automatically through API call.

So i want to find out the time difference between these two(opentime - currenttime), how can i able to convert the opentime into my server time.

I tried the following code in my-sql query,

TIMESTAMPADD(MINUTE,-180,FROM_UNIXTIME(opendate) // subtracting 3 hours(180 min) from the opendate.

Is there any other way to do this?

Advance thanks for your guidance.

  • 写回答

2条回答 默认 最新

  • doucan1979 2012-10-22 06:13
    关注

    You can change the default time zone for MySQL. This can be set as a default for your MySQL server, or on the fly with each connection. Something like this:

    set timezone='your timezone';
    

    http://dev.mysql.com/doc/refman/5.5/en//time-zone-support.html

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题