🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    TZ magic in ESP/M5Unified

    Arduino
    1
    1
    281
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • W
      wsanders
      last edited by wsanders

      Mt RTC is set to UTC. Somehow, this magically works:

          setenv("TZ","PST8PDT",1);
          tzset();
          auto tm = localtime(&t);
          M5.Display.printf("ESP32 %04d/%02d/%02d (%s)  %02d:%02d:%02d\r\n",
                tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
                wd[tm->tm_wday],
                tm->tm_hour, tm->tm_min, tm->tm_sec);
      

      Just posting here in case someone is mystified by the Rtc.ino example, since it doesn't set the TZ "environment variable" the calls to localtime and gmtime will return the same.

      1 Reply Last reply Reply Quote 1
      • First post
        Last post