如果服务器位于不同的位置,如何保存客户端机器时间
16lz
2021-01-22
I have to save the date and time of booking in the database after the successful booking. I have tried like the following
成功预订后,我必须在数据库中保存预订的日期和时间。我尝试过如下
if(bookingSuccess){
DateTime bookingDate = new DateTime ();
storeDate(bookingDate );
}
storeDate(DateTime date){
....
}
but it wont work if the server is in one location and the client is in another location. Please suggest any solution for this.
但如果服务器位于一个位置且客户端位于另一个位置,它将无法工作。请为此建议任何解决方案。
2 个解决方案
#1
0
run java script code on client side to get current time
在客户端运行java脚本代码以获取当前时间
var d = new Date();
while saving the booking entries , you can get the current time of user machine and save it in a variable. If booking is successful then save that time.
保存预订条目时,您可以获取用户计算机的当前时间并将其保存在变量中。如果预订成功,则保存该时间。
steps:
- fetch booking details and current time of client
- save booking
- when booking is successful then save client time if server and client are on different locations
获取预订详情和客户的当前时间
预订成功后,如果服务器和客户端位于不同位置,则节省客户端时间