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. Wrong Time Zone
Forum Updated to NodeBB v4.3 + New Features

Wrong Time Zone

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 1.8k Views 3 Watching
  • 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.
  • H Offline
    H Offline
    heedaf
    wrote on last edited by
    #1

    I've got the following code

    QDateTime timestamp = QDateTime::currentDateTime();
    timestamp.setTimeSpec(Qt::LocalTime); 
         text = timestamp.toString("hh:mm:ss");
    

    But the result shows UTC instead of my timezone. I'm using Win7 and I have the correct timezone listed. Any idea what the problem is?

    1 Reply Last reply
    0
    • Chris KawaC Online
      Chris KawaC Online
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      currentDateTime returns time already in local time spec/zone, so the next line does nothing. Verify if the correct time zone/spec is used e.g. by printing:

      qDebug() << timestamp.timeZone().displayName(timestamp) << timestamp.timeSpec();
      
      1 Reply Last reply
      0
      • H Offline
        H Offline
        heedaf
        wrote on last edited by
        #3

        Thanks for your reply.

        timeZone() in timestamp.timeZone() doesn't come up and gives an error.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mcosta
          wrote on last edited by
          #4

          Hi and welcome to devnet,

          build error or runtime error?
          Could you post the error?

          Once your problem is solved don't forget to:

          • Mark the thread as SOLVED using the Topic Tool menu
          • Vote up the answer(s) that helped you to solve the issue

          You can embed images using (http://imgur.com/) or (http://postimage.org/)

          1 Reply Last reply
          0
          • Chris KawaC Online
            Chris KawaC Online
            Chris Kawa
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Did you #include <QTimeZone>?
            For the future - if you get an error you should post what it says. We don't have a crystal ball you know ;)

            1 Reply Last reply
            0
            • H Offline
              H Offline
              heedaf
              wrote on last edited by
              #6
              This post is deleted!
              1 Reply Last reply
              0

              • Login

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