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. QDate
Qt 6.11 is out! See what's new in the release blog

QDate

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 311 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.
  • E Offline
    E Offline
    ELIF
    wrote on last edited by
    #1

    Hello I want to write program that calculates the time in milliseconds from 01.01.1970 to now.

    I try

    QDateTime::currentMSecsSinceEpoch() - QDateTime(QDate::currentDate()).toMSecsSinceEpoch()
    

    to calculate 1 day in Mseconds. I cant multiple it with days number since 1970.

    There has to be an easy way, I just havn't found it yet...

    Thank you.

    Christian EhrlicherC JonBJ 2 Replies Last reply
    0
    • E ELIF

      Hello I want to write program that calculates the time in milliseconds from 01.01.1970 to now.

      I try

      QDateTime::currentMSecsSinceEpoch() - QDateTime(QDate::currentDate()).toMSecsSinceEpoch()
      

      to calculate 1 day in Mseconds. I cant multiple it with days number since 1970.

      There has to be an easy way, I just havn't found it yet...

      Thank you.

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @ELIF said in QDate:

      that calculates the time in milliseconds from 01.01.1970 to now.

      auto timeInMSecsSince1970 = QDateTime(QDate::currentDate()).toMSecsSinceEpoch()

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2
      • E ELIF

        Hello I want to write program that calculates the time in milliseconds from 01.01.1970 to now.

        I try

        QDateTime::currentMSecsSinceEpoch() - QDateTime(QDate::currentDate()).toMSecsSinceEpoch()
        

        to calculate 1 day in Mseconds. I cant multiple it with days number since 1970.

        There has to be an easy way, I just havn't found it yet...

        Thank you.

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

        @ELIF said in QDate:

        to calculate 1 day in Mseconds

        24 * 60 * 60 * 1000 ?

        I cant multiple it with days number since 1970.

        time(NULL) * 1000ULL ?

        Not saying you should not do it as @Christian-Ehrlicher as shown with Qt call, just saying this is not hard! :)

        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