#include <stdio.h>
#include <time.h>
#include <sys/time.h>
#include <unistd.h>
int main() {
struct timeval tv;
// Get current time
if (gettimeofday(&tv, NULL) != 0) {
perror("gettimeofday");
return 1;
}
// Subtract 1 hour (3600 seconds)
tv.tv_sec -= 3600;
// Set the new time
if (settimeofday(&tv, NULL) != 0) {
perror("settimeofday (are you root?)");
return 1;
}
printf("System time set to 1 hour earlier: %s", ctime(&tv.tv_sec));
return 0;
}