跳到主要内容

How do I handle timezone for my devices?

ESP RainMaker provides automatic timezone management:

  1. Enable time service:

    esp_rmaker_time_service_enable();
  2. Get current time:

    time_t now;
    time(&now);
    struct tm timeinfo;
    localtime_r(&now, &timeinfo);

The timezone is automatically set based on the user's account settings in the phone app.

For more details, see Time Service Usage.