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. QDateTime Question
Forum Updated to NodeBB v4.3 + New Features

QDateTime Question

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 361 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.
  • L Offline
    L Offline
    leinad
    wrote on last edited by
    #1

    If I do something like this:
    QDateTime dt;
    QString updatedTime = NULL;

    dt.setSecsSinceEpoch(0); //zero seconds
    updatedTime = dt.toString("yyyy-MM-dd hh:mm:ss");

    I would expect to get "1970-01-01-12:00.00" but instead I get "1969-12-31 19:00:00". It seems there is an offset that I'm missing.

    Can someone tell me why?

    Thanks

    JonBJ 1 Reply Last reply
    0
    • L leinad

      If I do something like this:
      QDateTime dt;
      QString updatedTime = NULL;

      dt.setSecsSinceEpoch(0); //zero seconds
      updatedTime = dt.toString("yyyy-MM-dd hh:mm:ss");

      I would expect to get "1970-01-01-12:00.00" but instead I get "1969-12-31 19:00:00". It seems there is an offset that I'm missing.

      Can someone tell me why?

      Thanks

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @leinad said in QDateTime Question:

      It seems there is an offset that I'm missing.

      Local time (which is what DateTime::toString() outputs)? What timezone are you in?? USA EST (UTC -5 hours) perchance? :)

      Perhaps you are looking to use QDateTime QDateTime::toUTC() const ? See the example code there, and also int QDateTime::offsetFromUtc() const.

      1 Reply Last reply
      2
      • L Offline
        L Offline
        leinad
        wrote on last edited by
        #3

        I'm USA EST so I need to add UTC + 5 hours?

        JonBJ 1 Reply Last reply
        0
        • L leinad

          I'm USA EST so I need to add UTC + 5 hours?

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @leinad
          (a) I have already answered and given you the links, and (b) you really ought know what you have to do to a USA time to reach a UTC/GMT/UK time!!!

          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