man time.h
The basic idea, for creating a timer, is to create something to store the time. Typically this is a struct of type 'time_t'. You then grab the current time via a call to 'time()', usually passing NULL as the argument. All of this is done before you begin a timer loop. The timer loop is relatively easy as well; just keep a temporary copy of the current time that you update continuously. When you've reached the time limit(meaning your first saved time & your current time are 30 seconds apart, in this case), you end the timer loop.
There are some better methods as well, such as actually using an alarm, or setting a system timer, etc.
Good luck.