ESP32 SNTP SYNC not working for GMT?

Hi,
is the time format (as in setenv(TZ,) ) with “GMT+XX” supported?
I keep trying to set my time with

void init_sntp()
{
  if (isSet())
  {
    ESP_LOGW(TAG, "init_sntp called although already set inited_sntp: %d", inited_sntp);
  }
  initialize_sntp();

  time_t now = 0;
  struct tm timeinfo = {0};

  int retry = 0;
  const int retry_count = 10;
  while (sntp_get_sync_status() == SNTP_SYNC_STATUS_RESET && ++retry < retry_count)
  {
    ESP_LOGI(TAG, "Waiting for system time to be set... (%d/%d)", retry, retry_count);
    vTaskDelay(2000 / portTICK_PERIOD_MS);
  }
  ESP_LOGI(TAG, "sntp_get_sync_status() %d", sntp_get_sync_status());
  time(&now);
  localtime_r(&now, &timeinfo);
  print_now();
  if (retry >= retry_count)
  {
    ESP_LOGW(TAG, "SNTP sync failed!");
  }
}

initializing it with:

 void initialize_sntp(void)
{
  if (inited_sntp)
    return;
  inited_sntp = true;
  ESP_LOGI(TAG, "Initializing SNTP to %s ", MgConfig::instance()->tz_.c_str());

  //setenv("TZ", MgConfig::instance()->tz_.c_str(), 1);
  setenv("TZ", "CST-8", 1);
  tzset();

  sntp_setoperatingmode(SNTP_OPMODE_POLL);
  sntp_setservername(0, "pool.ntp.org");
  sntp_init();
}

and printing it with:

 void print_now()
{
  time_t now;
  char strftime_buf[64];
  struct tm timeinfo;
  localtime_r(&now, &timeinfo);
  strftime(strftime_buf, sizeof(strftime_buf), "%c", &timeinfo);
  ESP_LOGI(TAG, "The current date/time in %s is %s", MgConfig::instance()->tz_.c_str(), strftime_buf);
}

I keep getting impossible time values like:
I (11108) time-mod: The current date/time in New York is: Thu Jan 1 00:00:00 1970
and even after going back to CST-8 and not setting the time myself it still seems wrong, though with CST i just get epoch ß and with GMT+2 (which is what my config object returns) i get some bizzare values that jump around from 1901 to 2004 and back again.

Did i kill something with GMT ? is that supported ? how can i get this to function properly ?

sntp_sync_time just returns 0 so i really do not know what’s wrong

The Arduino-ESP32 people (Issues · espressif/arduino-esp32 · GitHub) will know that best.

I asked that already

But I got just tagged as a dupe but can’t find anyone with the same issue on the forum … which leaves me again with no idea what to do

Ah that is ESP-IDF?

In the forum someone left a comment saying (S)NTP sync does not seem successfull, not marked as duplicate.

Also for reproduction purporses it would be good to have the full, minimal example which reproduces the problem – the code above is using custom classes & global variables which are not further defined.

Correct, you seem to refer to this sntp: how to know if the time sync is done properly - Page 2 - ESP32 Forum

When making a minimum example i got it to work again, but the values are wrong by 4 hours?

Seems i must’ve missed something if the example does get it to work while my implementation fials.
But it’s still not accurate time.
I want GMT+2, but get GMt+2 minus 4 hours