J'ai un horodatage Unix et je dois le convertir en date lisible par l'homme. Comment peut-il être fait en Qt?Comment convertir les photos timestamp en Qt?
12
A
Répondre
20
int unixTime = 1234567890;
QDateTime timestamp;
timestamp.setTime_t(unixTime);
qDebug() << timestamp.toString(Qt::SystemLocaleShortDate);
Cela devrait vous aller. Comme l'a dit Matthew, voir QDateTime.setTime_t, ainsi que QDateTime.toString. Le toString a une énumération avec plusieurs options différentes, ainsi qu'une surcharge où vous pouvez passer une chaîne permettant cependant beaucoup de personnalisation que vous aimez.
6
1
Un bon exemple
qint64 qiTimestamp=QDateTime::currentMSecsSinceEpoch();
QDateTime dt;
dt.setTime_t(qiTimestamp/1000);
ui->lineEdit_DateTime->setText(dt.toString("yyyy-MM-dd hh:mm:ss"));
0
Vous pouvez utiliser la fonction statique: "fromTime_t", comme:
qDebug() < < QDateTime :: fromTime_t (your_time_stamp) .toString ("dd/MM/aaaa hh: mm: ss ");
Questions connexes
- 1. Convertir timestamp en alphanum
- 2. Comment convertir les photos LPCTSTR en LPSTR?
- 3. Comment convertir les photos TimePrimitive en int?
- 4. Comment convertir les photos Decimal en T?
- 5. Comment convertir les photos CST en PST?
- 6. Convertir UTC en Unix Timestamp
- 7. Comment convertir les photos RGB555 en RGB888 en C#?
- 8. convertir unix timestamp php
- 9. Comment convertir les photos Inverse Fast Fourier Transform en .wav?
- 10. Comment convertir datetime en timestamp unix en c?
- 11. Convertir une date de chaîne en timestamp
- 12. Convertir timestamp MYSQL à time_t
- 13. convertir timestamp mysql à mktime
- 14. Comment convertir l'horodatage long en timestamp UTC sur l'objectif C
- 15. Comment convertir DATE UNIX TIMESTAMP en script shell sur MacOS
- 16. ffmpeg convertir film framerate variable en photos
- 17. Linq - Comment convertir les photos de plates à hiérarchiques?
- 18. Convertir la date RFC 1123 en timestamp en PHP
- 19. Protégez les photos, comment?
- 20. Comment convertir les photos ISO-8859-1 en UTF-8 (Javascript)?
- 21. Convertir le format de date de mysql TIMESTAMP help
- 22. JavatoC# (Timestamp)
- 23. Comment comparer timestamp MySQL
- 24. Comment faire pour convertir la date de la chaîne en Timestamp in java?
- 25. mysql timestamp convertion
- 26. Comment convertir char * en PRUnichar *
- 27. Comment ajouter un espacement dynamique entre les contrôles? (avec photos)
- 28. Javascript TimeStamp
- 29. Comment faire pour classer les photos par catégorie en php
- 30. obtenir les photos facebook