How to Set RTC in ES32 using NTP server?
this snippet from setup() sets on esp32 the NTP for internal RTC and uses epoch seconds to set time to TimeLib library.
  configTime(gmtOffset_sec, daylightOffset_sec, &quot;pool.ntp.org&quot;);
  time_t now = time(nullptr);
  while (now &lt; SECS_YR_2000) {
    delay(100);
    now = time(nullptr);
  }
  setTime(now);

The ESP32 examples library in IDE examples folder has example SimpleTime.