QT 时间戳

UTC时间戳

  QDateTime time ;

time = QDateTime::fromString(strBuffer, "yyyyMMddhhmmsszzz");
        time.setTimeSpec(Qt::UTC);
        long long seconds2 = time.toMSecsSinceEpoch(); // 13位时间戳

     int nTimeStap = time.toTime_t();//10位时间戳

本地时间戳:

QDateTime time ;

time = QDateTime::fromString(strBuffer, "yyyyMMddhhmmsszzz");
        //time.setTimeSpec(Qt::LocalTime);
        long long seconds2 = time.toMSecsSinceEpoch(); // 13位时间戳

     int nTimeStap = time.toTime_t();//10位时间戳

猜你喜欢

转载自blog.csdn.net/qq_16628589/article/details/86010088