Time synchronization and localization are basic services in a sensor network system. Although they often depend on each other, they are usually tackled independently. In this work, we investigate the time synchronization and localization problems in underwater sensor networks, where more challenges are introduced because of the unique characteristics of the water environment. These challenges include long propagation delay and transmission delay, low bandwidth, energy constraint, mobility, etc. We propose a joint solution for localization and time synchronization, in which the stratification effect of underwater medium is considered, so that the bias in the range estimates caused by assuming sound waves travel in straight lines in water environments is compensated. By combining time synchronization and localization, the accuracy of both are improved jointly. Additionally, an advanced tracking algorithm IMM (interactive multiple model) is adopted to improve the accuracy of localization in the mobile case. Furthermore, by combining both services, the number of required exchanged messages is significantly reduced, which saves on energy consumption. Simulation results show that both services are improved and benefit from this scheme.