The intellisense error part of this topic is a duplicate of Identifier is undefined - setenv tzset.
The not working during runtime is another issue. Assuming this is a ESP32 project, have you tried using the latest Arduino-ESP32 by setting platform = https://github.com/Jason2866/platform-espressif32.git
in the platformio.ini
?