Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Force QDateTime.toString() to display UTC time
QtWS25 Last Chance

Force QDateTime.toString() to display UTC time

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 651 Views
  • 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.
  • Q Offline
    Q Offline
    Queequeg
    wrote on 8 Mar 2021, 09:26 last edited by
    #1

    How do I force QDateTime.toString () to display UTC time?
    If I change the time zone on my computer, then the output of the function also changes. It's pretty obvious, so I added setTimeSpec(Qt::UTC) but it still doesn't work!
    I think I am using this incorrectly?
    How can I force toString to output timestamp exclusively in UTC format without being bound to the local machine time zone?

    This code:
    e0f0e2e7-4c86-4029-93d9-e9b1920e6668-image.png
    Output:
    1b8dcec9-b458-4083-b54f-c2e2ec5e174a-image.png

    This code:
    b776796b-7900-44f2-b41c-945a251dd5b0-image.png
    Output:
    10f4acbd-7fa4-48c8-8663-45bc4cb3e449-image.png

    1 Reply Last reply
    0
    • A Offline
      A Offline
      artwaw
      wrote on 8 Mar 2021, 09:29 last edited by
      #2

      As stated in the documentation you need to use QDateTime::toUTC().

      For more information please re-read.

      Kind Regards,
      Artur

      Q 1 Reply Last reply 8 Mar 2021, 09:38
      4
      • A artwaw
        8 Mar 2021, 09:29

        As stated in the documentation you need to use QDateTime::toUTC().

        Q Offline
        Q Offline
        Queequeg
        wrote on 8 Mar 2021, 09:38 last edited by
        #3

        @artwaw Yes, really, thanks, missed it!

        1 Reply Last reply
        0

        1/3

        8 Mar 2021, 09:26

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved