ESP32 feedback from NTP
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(&amp;timeinfo)){
    Serial.println(&quot;Failed to obtain time&quot;);
    return;
  }
  Serial.println(&amp;timeinfo, &quot;%A, %B %d %Y %H:%M:%S&quot;);
}

getLocalTimereturns false on failure. Let the printLocalTime do the same.
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;
}

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