[英]Date/time issue with different zone
Spring boot application i set globally time zone UTC. Spring Boot应用程序我设置了全球时区UTC。 so that client (Angular) they are displaying based on user time zone that is correct working.
以便他们根据正确的用户时区显示客户端(角度)。 But the problem is we are searching the record based on changed date.
但是问题是我们正在根据更改的日期搜索记录。 How to solve that issue?
如何解决这个问题?
Example: 例:
It is their(Front-end developer's) responsibility to send UTC date to server and server will return the results based on UTC only and then they can convert dates in user's timezone. 将UTC日期发送到服务器是他们(前端开发人员)的责任,服务器将仅基于UTC返回结果,然后他们可以在用户的时区中转换日期。
So the conclusion is the server will be handling only one timezone which is UTC. 因此结论是服务器将仅处理一个时区,即UTC。
Ask angular developer to convert the date into UTC and send it to server. 要求Angular开发人员将日期转换为UTC并将其发送到服务器。
@Jack ...尝试一下它将解决
spring.datasource.url=jdbc:mysql://localhost:3306/veta?useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC
I fixed above issue using mysql query 我使用mysql查询修复了上述问题
In MySQL the CONVERT_TZ() returns a resulting value after converting a datetime value from a time zone specified as the second argument to the time zone specified as the third argument. 在MySQL中,CONVERT_TZ()在将datetime值从指定为第二个参数的时区转换为指定为第三个参数的时区后,返回结果值。 This function returns NULL when the arguments are invalid.
当参数无效时,此函数返回NULL。
CONVERT_TZ (dt, from_tz,to_tz)
Name Description
dt A datetime.
from_tz A time zone which will be converted to to_tz.
to_tz A time zone in which the from_tz will convert.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.