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. [Solved] how to convert QDateTime to GMT Unix Stamp
Forum Update on Monday, May 27th 2025

[Solved] how to convert QDateTime to GMT Unix Stamp

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 4.6k 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.
  • B Offline
    B Offline
    bhupi012
    wrote on 22 Sept 2014, 06:38 last edited by
    #1

    I am trying to convert QDateTime to Unix Time Stamp

    QDateTime PubDate = audioFile->GetPublishingdate();

    uint UTC_Time = PubDate.toTime_t();

    For Today,s date "Mon 22. Sep 00:00:00 2014" I am getting this 1411358400 TimeStamp Generated

    if i use this website http://www.epochconverter.com/ to check timestamp it is correct if I select Local Time but I want to generate timestamp according to GMT Time Which is 1411344000 for today's Date. I tried various other things.

    I am not getting how to get this time stamp

    Thanks for help in advance

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JKSH
      Moderators
      wrote on 22 Sept 2014, 07:01 last edited by
      #2

      Hi,

      PubDate is using local time. You need to tell it to use UTC (GMT) time before you call toTime_t()

      See the "QDateTime documentation":http://qt-project.org/doc/qt-5/qdatetime.html for info about time zones and Qt::TimeSpec

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • B Offline
        B Offline
        bhupi012
        wrote on 22 Sept 2014, 07:30 last edited by
        #3

        Thanks

        PutDate.setTimeSpec(Qt::UTC);

        This solved problem

        1 Reply Last reply
        0

        1/3

        22 Sept 2014, 06:38

        • 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