Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在MySQL中将Unix时间转换为IST_Mysql - Fatal编程技术网

在MySQL中将Unix时间转换为IST

在MySQL中将Unix时间转换为IST,mysql,Mysql,我使用下面的方法将存储在MySQL数据库的hltime列中的Unix时间转换为可读格式-“YYYY-DD-MM hh:MM:ss” 例如: UTC日期和时间在MySQL数据库中的存储格式:1500473820 用于转换为可读格式的MySQL函数: from_unixtime(hltime,'%Y %D %M %h:%i:%s') 结果:“2017年7月19日07:47:00” hltime列中存储的日期和时间以GMT为单位。因此,如何使用from_unixtime()函数(或任何其他函数

我使用下面的方法将存储在MySQL数据库的
hltime
列中的Unix时间转换为可读格式-“YYYY-DD-MM hh:MM:ss”

例如:

  • UTC日期和时间在MySQL数据库中的存储格式:
    1500473820

  • 用于转换为可读格式的MySQL函数:

    from_unixtime(hltime,'%Y %D %M %h:%i:%s')
    
  • 结果:“2017年7月19日07:47:00”

hltime
列中存储的日期和时间以GMT为单位。因此,如何使用
from_unixtime()
函数(或任何其他函数)将显示的值转换为IST(印度标准时间)


我尝试过使用
convert\u tz(从\u unixtime(hltime,%Y-%D-%M%h:%I:%s'),“+00:00”,“+06:00”)
,但我得到了
NULL
值。

用于转换的日期时间格式不正确

更改

'%Y %D %M %h:%i:%s'
'%Y-%m-%d %h:%i:%s'
----------  -------------------  ---------------------
        ut  gmt                  ist                  
----------  -------------------  ---------------------
1500473820  2017-07-19 07:47:00  2017-07-19 13:17:00  

'%Y %D %M %h:%i:%s'
'%Y-%m-%d %h:%i:%s'
----------  -------------------  ---------------------
        ut  gmt                  ist                  
----------  -------------------  ---------------------
1500473820  2017-07-19 07:47:00  2017-07-19 13:17:00  
它应该是有效的

示例

SELECT @ut:= 1500473820 AS ut
     , @ts:=FROM_UNIXTIME(@ut,'%Y-%m-%d %h:%i:%s') AS gmt
     , CONVERT_TZ(CAST( @ts AS DATETIME ),'+00:00','+05:30') AS ist;
结果

'%Y %D %M %h:%i:%s'
'%Y-%m-%d %h:%i:%s'
----------  -------------------  ---------------------
        ut  gmt                  ist                  
----------  -------------------  ---------------------
1500473820  2017-07-19 07:47:00  2017-07-19 13:17:00