<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                [TOC] ## 概述 處理日期和時間的函數 ## 示例 ### 當前時間和日期 ``` QDateTime currentDateTime = QDateTime::currentDateTime(); qDebug() << "Current Date and Time:" << currentDateTime.toString("yyyy-MM-dd hh:mm:ss"); ``` ### 根據日期和時間 ``` QDate date(2023, 9, 8); QTime time(14, 30); QDateTime customDateTime(date, time); qDebug() << "Custom Date and Time:" << customDateTime.toString("yyyy-MM-dd hh:mm:ss"); ``` ### 計算日期差距 ``` QDate date1(2023, 9, 1); QDate date2(2023, 9, 8); int daysBetween = date1.daysTo(date2); qDebug() << "Days between date1 and date2:" << daysBetween; ``` ### 添加時間間隔 ``` QDateTime dateTime(2023, 9, 8, 14, 30); QTimeSpan timeSpan(2, 30); // 2小時30分鐘 dateTime = dateTime.addSecs(timeSpan.totalMilliseconds() / 1000); qDebug() << "New Date and Time:" << dateTime.toString("yyyy-MM-dd hh:mm:ss"); ``` ### 比較日期和時間 ``` QDateTime dateTime1(2023, 9, 8, 10, 0); QDateTime dateTime2(2023, 9, 8, 14, 30); if (dateTime1 < dateTime2) { qDebug() << "dateTime1 is before dateTime2."; } else { qDebug() << "dateTime1 is after or equal to dateTime2."; } ``` ### 解析日期和時間字符串 ``` QString dateTimeString = "2023-09-08 14:30:00"; QDateTime parsedDateTime = QDateTime::fromString(dateTimeString, "yyyy-MM-dd hh:mm:ss"); qDebug() << "Parsed Date and Time:" << parsedDateTime.toString("yyyy-MM-dd hh:mm:ss"); ``` ### 獲取日期和時間的各個部分 ``` QDateTime dateTime = QDateTime::currentDateTime(); int year = dateTime.date().year(); int month = dateTime.date().month(); int day = dateTime.date().day(); int hour = dateTime.time().hour(); int minute = dateTime.time().minute(); int second = dateTime.time().second(); qDebug() << "Year:" << year << "Month:" << month << "Day:" << day << "Hour:" << hour << "Minute:" << minute << "Second:" << second; ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看