Questions tagged [qdatetime]

A QDateTime is a class from the Qt toolkit which provides functions for working with both dates and times.

A QDateTime object is a combination of the QDate and QTime classes which contains information about a calendar date and clock time. It can read the current date and time from the system clock, and also provides functions for comparing, formatting and parsing date/times, and for performing basic date/time calculations.

The official documentation can be found here.

88 questions
1
vote
1 answer

Qt QDateTime nanoseconds from 1/1/1970

I am about to read data From a File which has stored it's time in nanoseconds from 1/1/1970. My problem is I want to read it to a QDateTime object, but it simply does not work as I want it to and the Qt Documentation did not help me either. Note:…
drahnr
  • 6,782
  • 5
  • 48
  • 75
1
vote
0 answers

How can I print a timestamp with RFC 2822 style time zone in Qt5?

I would like to format a QString to hold a description of a timestamp with offset from UTC specified on RFC 2822 format like this: +0800 for a positive offset of 8 hours, or -0100 for a negative offset of 1 hour. I have studied the official…
Mr. Developerdude
  • 9,118
  • 10
  • 57
  • 95
1
vote
2 answers

QTimeDate::currentDateTime not working as expected

i'm trying to use QDateTime for one of my project. But everything is going wrong when i use QDateTime::currentTime().msecsTo() .... QString FORMAT = "d/MM/yy hh:mm:ss"; QDateTime at = QDateTime::fromString("30/06/15 12:00:00", FORMAT); qDebug() <<…
1
vote
1 answer

QDateTime Conversion

I need to convert the String variable to QDateTime format my code looks QString date ="Thu Jun 18 2015"; QDateTime tmp = QDateTime::fromString(date,"ddd MMM dd yyyy HH:mm:ss"); But the result is Thu Jan 1 00:00:00 1970. Later I have to convert…
Haris
  • 13,645
  • 12
  • 90
  • 121
1
vote
1 answer

QDateTime::fromMSecsSinceEpoch not works correctly

I'm trying to convert this value (1426519114913) that is a unix timestamp, to QDateTime object. for doing this we have fromMSecsSinceEpoch function in QDateTime that converts msecs from epoch to DateTime object. but I was unsuccessfull, for testing…
mesut
  • 2,099
  • 3
  • 23
  • 35
1
vote
1 answer

Qt5 (C++) conversion from GMT/UTC string to UNIX timestamp

I am trying to convert from a GMT/UTC string like this: 11 Sep 2014 14:31:50 GMT to UNIX timestamp in Qt (c++). Here's the code (note that I have removed " GMT" from the first string): QString l_time = "11 Sep 2014 14:31:50"; QDateTime l_dt =…
JuanDeLosMuertos
  • 4,532
  • 15
  • 55
  • 87
1
vote
1 answer

QDateTime widget looks bad under Mac OS X

I have a project based on Qt 5.2.1 and it has QDateTime widget with calendar pop-up (calendarPopup option set on true). When i run my app under Ubuntu 13.10 (or looking in Qt Designer) QDateTime looks like: and it's OK. But under Mac OS X 10.9.2 it…
serg.v.gusev
  • 501
  • 4
  • 13
1
vote
1 answer

Trouble with QDateTime::fromMSecsSinceEpoch

I try to read seconds after 1970 to a QDateTime. I.e.: startT = 1.390309552938E9 Therefor I use: QDateTime time = QDateTime::fromMSecsSinceEpoch(startT*1000); // *1000 because a have seconds while qt expecting milliseconds now I want to compare…
smaica
  • 723
  • 2
  • 11
  • 26
1
vote
1 answer

Pack timestamp in 4 bytes

I am very restricted in memory usage. I need to store a datetime in my program. Precision is one second. Only 4 bytes for one datetime value. What is the best way to achieve this?
tmporaries
  • 1,523
  • 8
  • 25
  • 39
1
vote
2 answers

Problems to convert a QString to QDateTime

i have a problem to convert a QString to a QDataTime-Object. The String looks like: "2008:09:23 14:18:03 and have a length of 20. The Problem is, if i remove the first character the output looks like: "008:09:23 14:18:03. That's wrong with it? Can i…
501 - not implemented
  • 2,638
  • 4
  • 39
  • 74
0
votes
2 answers

QDateTime::fromString not accepting my QString?

I have a .txt file which is filled with lines like this below: 2011-03-03 03.33.13.222 4 2000 Information BUSINESS ...etc blabla 2011-03-03 03.33.13.333 4 2000 Information BUSINESS ...etc blabla 2011-03-03 03.33.13.444 4 2000 …
PathOfNeo
  • 1,089
  • 4
  • 21
  • 39
0
votes
1 answer

Date string with zone info (QTimeZone) to QDateTime and reverse

I want to use PyQt6 with QDateTime. Here's the problem. The first entry is ok. But turning the TEST switch to 1 or 2 will cause various errors. In particular, dealing with the time zones. I know that the QTimeZone has other time zones, but how do I…
Marvin
  • 1
0
votes
0 answers

Question on formatting when converting Pyside QDateTime data to String

here is my test code, utc_fmt = "yyyy/MM/dd hh:mm:ss.zzzzzz" new_date = QDateTime().fromString("2023/01/01 20:19:18.171123", utc_fmt) debug =new_date.toString("yyyy/MM/dd hh:mm:ss.zzzzzz") …
Rui
  • 97
  • 1
  • 8
0
votes
1 answer

Animate focused part of QDateTimeEdit

I need to animate QDateTimeEdit widget as follows; When user focuses/edits year section, it should be animated using opacity property. ( like flickering, show and hide for every second ) Qt animation could only be used for widgets. But the part I'm…
0
votes
0 answers

How to run the code between specific dates on QT

How can I run the function I want in the code in the time interval I selected in the code I wrote in Qt? How can I set up a signal slot structure? can you show sample code? for example in the code I want to run the function between 25.03.2022 and…
Mahmut
  • 7
  • 4