Here's something else I found:
clicky
Then scroll down to the time.h and look at the example program, seems like it has what you you are looking for, which is basically same as what DaWei said.
Only this is a ready-made code
ps: I couldn't read the descriptions of the time functions, Mozilla times me out

but example compiled and worked.