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

    ntptime.getTimestamp returns incorrect timestamp.

    Scheduled Pinned Locked Moved Micropython
    5 Posts 3 Posters 7.3k 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.
    • C Offline
      chhsiao
      last edited by

      version: UIFlow: v1.9.5

      code:

      text = M5Label('text', x=38, y=137, color=0x000, font=FONT_MONT_30, parent=None)
      text2 = M5Label('text', x=38, y=117, color=0x000, font=FONT_MONT_30, parent=None)
      ntp = ntptime.client()
      ts = ntp.getTimestamp()
      year = ntp.year()
      month = ntp.month()
      day = ntp.day()
      text.set_text('%s' % (ts))
      text2.set_text('%s-%s-%s' % (year, month, day))

      expected:
      corrected timestamp as now (2022-09-19 ish).
      saw: some strange timestamp in around 1992. (716937583)

      I'm wondering whether this is within expectation?

      ajb2k3A 1 Reply Last reply Reply Quote 0
      • ajb2k3A Offline
        ajb2k3 @chhsiao
        last edited by

        @chhsiao have you set the correct timeszone or tried a different time zone?
        1992 would imply that it doesn’t have a valid time click connection

        UIFlow, so easy an adult can learn it!
        If I don't know it, be patient!
        I've ether not learned it or am too drunk to remember it!
        Author of the WIP UIFlow Handbook!
        M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

        1 Reply Last reply Reply Quote 0
        • C Offline
          chhsiao
          last edited by

          hi @ajb2k3 ~

          Thank you so much for the reply.
          the year-month-day (text2) shows expected date-time though.
          I would assume that we do have successful ntp connection because of text2.
          In my real code, the time-server is set as our internal time-server, and the timezone is set as 0 (for UTC).

          1 Reply Last reply Reply Quote 0
          • C Offline
            chhsiao
            last edited by

            0_1663857818576_IMG_1182.jpg

            hi @ajb2k3 ~

            Thank you so much for the reply.

            As you can see from the screenshot:
            the year-month-day (text2) shows expected date-time though.
            I would assume that we do have successful ntp connection because of text2.
            In my real code, the time-server is set as our internal time-server, and the timezone is set as 0 (for UTC).

            1 Reply Last reply Reply Quote 0
            • O Offline
              ondrej1024
              last edited by

              Looks like this ntptime timestamp is relative to 01/01/2000, and not to 01/01/1970 like the Epoch Unix timestamp.

              1 Reply Last reply Reply Quote 0

              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