It is very important that all computers on a given network report the same time. This allows backups and other regularly scheduled events to be automated. Instead of manually adjusting the time on every computer in the network, you can designate a time server. The other computers can use the time server to determine the correct time and adjust their own clocks accordingly.
The code below, time.pl, contains a program that can retrieve the time from any time server in the world.
All you need to do is modify the example to access your own time server by setting the $remoteServer variable to your server's symbolic name.
Turn on the warning compiler option. Load the Socket module.
Initialize the $remoteServer to the symbolic name of the time server.
Set a variable equal to the number of seconds in 70 years. Initialize a buffer variable, $buffer.
Get the tcp protocol and time port numbers, provide a default in case the getprotobyname() and getservbyname() functions are notimplemented.
Initialize $serverAddr with the Internet address of the time server.
Display the current time on the local machine, also called the localhost.
Create a socket using the standard parameters. Initialize $packedFormat with format specifiers.
Connect the local socket to the remote socket that is providing the time service.
Read the server's time as a 4 byte value.
Unpack the network address from a long (4 byte) value into a string value.
Adjust the server time by the number of seconds in 70 years.
Display the server's name, the number of seconds difference between the remote time and the local time.
Return a string reflecting the time represented by the parameter.
Each operating system will have a different method to update the local time. So this needs to configures at your end -- good luck!!