Fog-based Vehicular ad-hoc networks (VANETs) are new kinds of network that combine fog computing and mobile ad-hoc networks appeared in recent years, which can be used in monitoring traffic, smart driving, safe driving, and so on. Fog-based VANET is composed of a large number of dynamic nodes and static nodes, which is a heterogeneous network. Due to the heterogeneity of fog-based VANET, there is a large difference in clock rate between different nodes. It makes clock of nodes soon become inconsistent. The inaccurate clocks would lead to problems such as imprecise duty-cycle scheduling and wrong events sequence, etc. Synchronizing the clocks needs multiple message exchanges among the nodes. However, due to the mobility of the fog-based VANET, the network topology changes dynamically, which may cause synchronization packets to fail to be transmitted to a node that needs to be synchronized. In this paper, a precise time synchronization mechanism for fog-based VANET is proposed. The mechanism uses two-way message exchange method to estimate clock offset through analyzing the mobility of dynamic nodes. Clock skew is corrected using a carrier frequency offset (CFO) based hardware clock frequency estimation and considering the Doppler effect. Theoretical analyses and simulation results show that our time synchronization mechanism achieves highly accurate time synchronization. INDEX TERMS Vehicular ad-hoc networks, fog computing, time synchronization, carrier frequency offset, two-way message exchange.