🤖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.

    Micropython
    3
    5
    4.9k
    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
      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
        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
          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
            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
              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
              • First post
                Last post