Linux provides the stime(2) call to set the system time. However, while this will update the system\'s time, it does not set the BIOS hardware clock to match the new system
After calling stime(), do this:
system("/sbin/hwclock --systohc");
See the hwclock(8) man page for more information.