🤖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

    Scheduled Pinned Locked Moved Arduino
    1 Posts 1 Posters 1.2k Views 1 Watching
    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 Offline
      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

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      • First post
        Last post