Time Zone Synchronization
I have a server which runs on Java and client which runs on python. When I connect the client and server I have to sync the time from server to cl开发者_C百科ient. I was successful in connecting and sending streams from server to client. I wanted to know what is the usual way to send time and timezone. How can i do it? For now i am sending time in miliseconds and paring that in python to get the date and time. But I don't know how to send time zone.
You should transmit and process the time in UTC and not mess with timezones at all. In Java, this is exactly what System.currentTimeMillis()
returns.
Edit: The correct format to transfer timezone information is to use a continent/city ID as in the tz database, e.g. "America/New_York" or "Europe/Berlin". This is also used by Java. The base timezone offset is insufficient because it cannot accomodate daylight savings time and historical timezone changes.
Do you know NTP, the Network Time Protocol?
精彩评论