A datacenter, which is a highly distributed multiprocessing system, needs to keep accurate track of time across a large number of machines. Precise time synchronization has become a critical component due to stringent requirements of several time critical applications such as real-time big data analytics, high-performance computing, and financial trading. Our study starts with a survey on the most relevant time synchronization techniques for datacenter networks. Then, we propose a zero-overhead microsecond-accuracy solution to synchronize a packet-switched optical network for datacenters. To achieve the desired time accuracy, we consider precision time protocol to synchronize the server clocks with a central controller clock. Zero-overhead is maintained by using data traffic to carry the time messages instead of a separate control channel. Through simulation, we show that microsecond level of time accuracy can be achieved. We also discuss the dependency of the accuracy on different traffic loads, traffic distributions, and packet lengths.