Platfomio y VScode error de compilacion con ESP32

estoy usandoVS code y platformio, encontre un codigo que conecta con el reloj en la web, con el ide de arduino funciona bien, pero en vs code platformio me tira este error, estoy usando un ESP32
este es el codigo

#include <Arduino.h>
#include <WiFi.h>
#include "time.h"

const char* ssid     = "MI_USUARIO";
const char* password = "MI_PASS";

const char* ntpServer = "pool.ntp.org";
const long  gmtOffset_sec = 0;
const int   daylightOffset_sec = 3600;

void setup(){
  Serial.begin(115200);

  // Connect to Wi-Fi
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi 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);
}

void loop(){
  delay(3000);
  printLocalTime();
}

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");
  Serial.print("Day of week: ");
  Serial.println(&timeinfo, "%A");
  Serial.print("Month: ");
  Serial.println(&timeinfo, "%B");
  Serial.print("Day of Month: ");
  Serial.println(&timeinfo, "%d");
  Serial.print("Year: ");
  Serial.println(&timeinfo, "%Y");
  Serial.print("Hour: ");
  Serial.println(&timeinfo, "%H");
  Serial.print("Hour (12 hour format): ");
  Serial.println(&timeinfo, "%I");
  Serial.print("Minute: ");
  Serial.println(&timeinfo, "%M");
  Serial.print("Second: ");
  Serial.println(&timeinfo, "%S");

  Serial.println("Time variables");
  char timeHour[3];
  strftime(timeHour,3, "%H", &timeinfo);
  Serial.println(timeHour);
  char timeWeekDay[10];
  strftime(timeWeekDay,10, "%A", &timeinfo);
  Serial.println(timeWeekDay);
  Serial.println();
}

este es el error

src\main.cpp: In function 'void setup()':
src\main.cpp:28:18: error: 'printLocalTime' was not declared in this scope
   printLocalTime();
                  ^
src\main.cpp: In function 'void loop()':
src\main.cpp:37:18: error: 'printLocalTime' was not declared in this scope
   printLocalTime();
                  ^
src\main.cpp: In function 'void printLocalTime()':
src\main.cpp:41:13: error: aggregate 'tm timeinfo' has incomplete type and cannot be defined
   struct tm timeinfo;
             ^
src\main.cpp:66:39: error: 'strftime' was not declared in this scope
   strftime(timeHour,3, "%H", &timeinfo);
                                       ^
*** [.pio\build\esp32dev\src\main.cpp.o] Error 1
======================================================== [FAILED] Took 4.55 seconds ==================================

Hola, el primer error que puedo observar es que la funcion printLocalTime debe ir antes del setup, en el id de arduino no importa donde lo pongas pero en platformio si, si quieres saber mas busca funciones prototipo ya que en C++ es obligatorio declarar una función antes de ser usada.

#include <Arduino.h>
#include <WiFi.h>
#include "time.h"

const char* ssid     = "MI_USUARIO";
const char* password = "MI_PASS";

const char* ntpServer = "pool.ntp.org";
const long  gmtOffset_sec = 0;
const int   daylightOffset_sec = 3600;

void printLocalTime(); // DECLARACION DE FUNCIONES PROTOTIPO

void setup(){
  Serial.begin(115200);

  // Connect to Wi-Fi
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi 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);
}

void loop(){
  delay(3000);
  printLocalTime();
}

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");
  Serial.print("Day of week: ");
  Serial.println(&timeinfo, "%A");
  Serial.print("Month: ");
  Serial.println(&timeinfo, "%B");
  Serial.print("Day of Month: ");
  Serial.println(&timeinfo, "%d");
  Serial.print("Year: ");
  Serial.println(&timeinfo, "%Y");
  Serial.print("Hour: ");
  Serial.println(&timeinfo, "%H");
  Serial.print("Hour (12 hour format): ");
  Serial.println(&timeinfo, "%I");
  Serial.print("Minute: ");
  Serial.println(&timeinfo, "%M");
  Serial.print("Second: ");
  Serial.println(&timeinfo, "%S");

  Serial.println("Time variables");
  char timeHour[3];
  strftime(timeHour,3, "%H", &timeinfo);
  Serial.println(timeHour);
  char timeWeekDay[10];
  strftime(timeWeekDay,10, "%A", &timeinfo);
  Serial.println(timeWeekDay);
  Serial.println();
}

Yo he puesto tu còdigo @Adrian_E en VSCode y no tuve problemas.

Building in release mode
Retrieving maximum program size .pio\build\nodemcuv2\firmware.elf
Checking size .pio\build\nodemcuv2\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [===       ]  33.4% (used 27344 bytes from 81920 bytes)   
Flash: [===       ]  25.2% (used 262852 bytes from 1044464 bytes)
======================================================================== [SUCCESS] Took 6.00 seconds ========================================================================
Terminal will be reused by tasks, press any key to close it.

Pero he seleccionado este ESP32 y comparalo con el tuyo

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino

si surbyte es la misma configuracion

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino

si declaro la funcion como debe ser en platformio antes del setup(), me salen estos errores

Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (3.0.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 3.10004.210126 (1.0.4)
 - tool-esptoolpy 1.30000.201119 (3.0.0)
 - toolchain-xtensa32 2.50200.80 (5.2.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 38 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Time>
|-- <WiFi> 1.0
Building in release mode
Compiling .pio\build\esp32dev\src\main.cpp.o
src\main.cpp: In function 'void printLocalTime()':
src\main.cpp:13:13: error: aggregate 'tm timeinfo' has incomplete type and cannot be defined
   struct tm timeinfo;
             ^
src\main.cpp:38:39: error: 'strftime' was not declared in this scope
   strftime(timeHour,3, "%H", &timeinfo);
                                       ^
*** [.pio\build\esp32dev\src\main.cpp.o] Error 1
======================================================== [FAILED] Took 3.62 seconds ========================================================
El proceso del terminal "C:\Users\NOAR\.platformio\penv\Scripts\platformio.exe 'run', '--environment', 'esp32dev'" finalizó con el código de salida 1.

Surbyte, te consulto comente esta linea

//#include "time.h"

y comenzo a funcionar lo mismo hice en el ide de arduino y tambien sigue funcionando, la pregunta es ¿la libreria time.h tambien es llamada internamente por la libreria arduino.h, o en cada package de cada placa? por eso lo del error en vs code con platformio?

No te comprendo, si declaras qué? Yo he tomado tu códgio inicial (del primer post) y en ese tu decìas que no funcionaba y a mi si.
Què es lo que esta o debe estar diferente?