Time Zones

Discussion in 'Plugin Development' started by Forseth11, Mar 17, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Forseth11

    Hello. I have 5 servers all using time in milliseconds. I am connecting to SQL to check server statuses. The host server (The one checking how many players and last time the server updated) has it's time in milliseconds off by about one full day. The funny thing is that all the servers are in the same building according to my host. Now my question is how do I get the current time in milliseconds that are all based off the same time. Is there a way to get the UTC time from the windows network.
     
  2. Offline

    msnijder30

  3. Offline

    Forseth11

    msnijder30 that will not work because all 5 of my server all run on a different machine, and each machine's system time is messed op. So they are all at the same location but one has its time 24 hours behind. The others are just off by a couple seconds.
     
  4. Offline

    willeb96

    I think System.currentTimeMillis() is independent of timezones.
     
  5. Offline

    nlthijs48

    willeb96 I also think that is the solution, since that method returns the following:
    I have used the method to check time before.
     
    willeb96 likes this.
  6. Offline

    Forseth11

  7. Offline

    nullschritt

    If I understand correctly, you want to base the times of all servers based off a single server? Why not just pull the time from one of the servers, and set the time of the others to match the time you just pulled?
     
  8. Offline

    ferrybig

  9. Offline

    blablubbabc

    I think you can also get the current time for a specific timezone via java's calendar. So if all servers use the same timezone to calculate their time from, then those should be sync.
     
  10. Offline

    Forseth11

    blablubbabc All the times are not in sync so getting the same time zone will make it so they are still just as far apart.

    ferrybig what is an ntp? If I have to get to the servers I can't only my host can.
     
  11. Offline

    ferrybig

    ntp stands for: Network time protocol, if you make your own implementation of system.currenttime, you can use a public ntp host to lookup what the differences are with the local time on the machines, and subtract that difference from the real system.timeMillies().
    Most used time host: pool.ntp.org
     
  12. Offline

    willeb96

    Can't you just set the correct time on your servers?
    If for some reason not, try using CURRENT_TIMESTAMP as the default value in your MySQL table.
     
Thread Status:
Not open for further replies.

Share This Page