You can use gmtime () and the tm structure to directly set this if you know the offsets.
If you know your local time and UTC, you know your local offset. If you also know the target offset, it is just a matter of setting tm_hour to the appropriate one (and possibly scrolling through the day if you go <0 or> 23).
For some sample code, see this gmtime man page . It shows the offset based on the offsets of the time intervals.
Edit:
In response to comments - you can also let mktime handle the shift for you, which allows you to simplify this conversion back to time_t. You can use something like:
time_t currentTime; tm * ptm; time ( ¤tTime ); ptm = gmtime ( &rawtime ); ptm->tm_hour += hours_to_shift; ptm->tm_minutes += minutes_to_shift;
Reed copsey
source share