user54202: The basic example for ESP32 NTP is very rough:
void setup() {
  Serial.begin(115200);
  
  //connect to WiFi
  Serial.printf("Connecting to %s ", ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
      delay(500);
      Serial.print(".");
  }
  Serial.println(" CONNECTED");
  
  //init and get the time
  configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
  printLocalTime();

  //disconnect WiFi as it's no longer needed
  WiFi.disconnect(true);
  WiFi.mode(WIFI_OFF);
}

But it tells nothing about the success of the operation.
I need to know if it was able to update the time from the NTP server. Is there a method to know that?
I can't rely on the time struct because I must init it manually at startup, say to 1st Jan 2020 00:00.

user10285: Did you follow that manual?
https://lastminuteengineers.com/esp32-ntp-server-date-time-tutorial/
The printLocalTime(); function does all you ask for.
void printLocalTime()
{
  struct tm timeinfo;
  if(!getLocalTime(&timeinfo)){
    Serial.println("Failed to obtain time");
    return;
  }
  Serial.println(&timeinfo, "%A, %B %d %Y %H:%M:%S");
}

getLocalTimereturns false on failure. Let the printLocalTime do the same.
boolean printLocalTime()
{
  struct tm timeinfo;
  if(!getLocalTime(&timeinfo)){
    Serial.println("Failed to obtain time");
    return false;
  }
  Serial.println(&timeinfo, "%A, %B %d %Y %H:%M:%S");
  return true;
}

Now the print function tells you if it failed (returns false) or not (returns true).

54202: <p>The basic example for ESP32 NTP is very rough:</p>
<pre><code>void setup() {
  Serial.begin(115200);
  
  //connect to WiFi
  Serial.printf(&quot;Connecting to %s &quot;, ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
      delay(500);
      Serial.print(&quot;.&quot;);
  }
  Serial.println(&quot; CONNECTED&quot;);
  
  //init and get the time
  configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
  printLocalTime();

  //disconnect WiFi as it's no longer needed
  WiFi.disconnect(true);
  WiFi.mode(WIFI_OFF);
}
</code></pre>
<p>But it tells nothing about the success of the operation.</p>
<p>I need to know if it was able to update the time from the NTP server. Is there a method to know that?</p>
<p>I can't rely on the time struct because I must init it manually at startup, say to 1st Jan 2020 00:00.</p>
 10285: <p>Did you follow that manual?</p>
<p><a href="https://lastminuteengineers.com/esp32-ntp-server-date-time-tutorial/" rel="nofollow noreferrer">https://lastminuteengineers.com/esp32-ntp-server-date-time-tutorial/</a></p>
<p>The <code>printLocalTime();</code> function does all you ask for.</p>
<pre><code>void printLocalTime()
{
  struct tm timeinfo;
  if(!getLocalTime(&amp;timeinfo)){
    Serial.println(&quot;Failed to obtain time&quot;);
    return;
  }
  Serial.println(&amp;timeinfo, &quot;%A, %B %d %Y %H:%M:%S&quot;);
}
</code></pre>
<p><code>getLocalTime</code>returns false on failure. Let the <code>printLocalTime</code> do the same.</p>
<pre><code>boolean printLocalTime()
{
  struct tm timeinfo;
  if(!getLocalTime(&amp;timeinfo)){
    Serial.println(&quot;Failed to obtain time&quot;);
    return false;
  }
  Serial.println(&amp;timeinfo, &quot;%A, %B %d %Y %H:%M:%S&quot;);
  return true;
}
</code></pre>
<p>Now the print function tells you if it failed (returns false) or not (returns true).</p>
