ESP8266 ISO 8601 string to tm struct I have a web service that returns timestamps in ISO 8601 format, e.g., &quot;2021-06-25T12:00:00&quot;
I'm trying to turn the timestamp string into a tm type struct from the ESP8266 library &lt;time.h&gt;, to perform time calculations using the difftime() function.
I've been referring to the Redhat time functions https://sourceware.org/newlib/libc.html#time, as it seem to be compatible with the ESP library, though all i can find are functions converting tm structs to timestamp strings. Are there any functions to convert a string timestamp into a tm struct and then back into epoch? Or what would be the best way to approach this kind of conversion on the ESP8266 platform?
Try strptime from the time.h.
void setup()
{
    
  struct tm tm = {0};
  char buf[100];
  
  // Convert to tm struct
  strptime(&quot;2001-11-12 18:31:01&quot;, &quot;%Y-%m-%d %H:%M:%S&quot;, &amp;tm);
  
  // Can convert to any other format
  strftime(buf, sizeof(buf), &quot;%d %b %Y %H:%M&quot;, &amp;tm);
  Serial.printf(&quot;%s&quot;, buf);
}

void loop()
{
    yield();
}