#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main() {
// Set the timezone to New York
setenv("TZ", "America/New_York", 1);
tzset();
// Get the current time
time_t now = time(NULL);
struct tm *local = localtime(&now);
printf("Current date and time in New York: %02d-%02d-%04d %02d:%02d:%02d\n",
local->tm_mday, local->tm_mon + 1, local->tm_year + 1900,
local->tm_hour, local->tm_min, local->tm_sec);
return 0;
}
/*
run:
Current date and time in New York: 27-02-2025 02:20:02
*/