Time synchronization is critical in distributed environments. A variety of network protocols, middleware and business applications rely on proper time synchronization across the computational infrastructure and depend on the clock accuracy. The "Network Time Protocol" (NTP) is the current widely accepted standard for synchronizing clocks over the internet. NTP uses a hierarchical scheme in order to synchronize the clocks in the network. In this talk we present a novel non-hierarchical peer-to-peer approach for time synchronization termed CTP - Classless Time Protocol. This approach exploits convex optimization theory in order to evaluate the impact of each clock offset on the overall objective function. We define the clock offset problem as an optimization problem and derive its optimal solution. Based on the solution we introduce a distributed protocol that can be implemented over a communication network, prove its convergence to the optimal clock offsets and show its properties. We also present methodology and numerical results for evaluating and comparing the accuracy of time synchronization schemes. We show that the CTP substantially outperforms hierarchical schemes such as NTP in the sense of clock accuracy with respect to a universal clock, without increasing complexity.