The function gettimeofday() can get the time as well as a timezone.
gettimeofday()
Read more in the Linux Reference.