For many algorithms you need the clock to be synchronized between the client and the server. Mirror does that automatically for you.
To get the current time use this code:
1
double now = NetworkTime.time;
Copied!
It will return the same value in the client and the servers. It starts at 0 when the server starts. Note the time is a double and should never be cast to a float. Casting this down to a float means the clock will lose precision after some time:
after 1 day, accuracy goes down to 8 ms
after 10 days, accuracy is 62 ms
after 30 days , accuracy is 250 ms
after 60 days, accuracy is 500 ms
Mirror will also calculate the RTT(round trip time) as seen by the application: