Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Date manipulations
Qt 6.11 is out! See what's new in the release blog

Date manipulations

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 1.0k Views 1 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.
  • F Offline
    F Offline
    Flamaros
    wrote on last edited by
    #1

    I didn't find how to count the number of days between two Date. I also need to be able to add a number of days to a Date and print the resulting Date.

    1 Reply Last reply
    0
    • mranger90M Offline
      mranger90M Offline
      mranger90
      wrote on last edited by
      #2

      You mean like QDate::daysTo() and QDate::addDays() ?
      Suggest you look at:
      http://qt-project.org/doc/qt-5.0/qtcore/qdate.html

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Flamaros
        wrote on last edited by
        #3

        Yes I need functions like this but in QML

        1 Reply Last reply
        0
        • F Offline
          F Offline
          Flamaros
          wrote on last edited by
          #4

          Ok it seems there is no official method to do it so I use :
          @
          function dateDiffInDays(date1, date2)
          {
          var timeDiff = Math.abs(date2.getTime() - date1.getTime());
          return Math.ceil(timeDiff / (1000 * 3600 * 24));
          }
          @

          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