Hello,

I have a string with my date and time and I need to convert this string to time_t.
My string format is: Sun Mar 04 23:25:13 2001
The epoch (time_t) for this string is: 983748313

The code I wrote is:

Qt Code:
  1. QString test = asctime(gmtime(&epoch));
  2. QDateTime dt = QDateTime::fromString(test,"ddd MMM dd hh:mm:ss yyyy");
  3. time_t testTime = dt.toTime_t();
To copy to clipboard, switch view to plain text mode 

I have the epoch/time_t (983748313), I'm using this code to check if I can convert to string (Sun Mar 04 23:25:13 2001) and then convert back to epoch, but when I print my convertion (testTime) gets: 4294967295.
If I check my variables, epoch is ok, QString test is ok, but dt data there is nothing inside (0,0,0,-1). I don't know if I need to do something else and I have no idea why it's not converting.

I would like to have the output:
epoch: 983748313
test: Sun Mar 04 23:25:13 2001
testTime: 983748313

Epoch and test are ok, but I still have problems to convert and have a testTime.

Can anyone help me with that?

Thanks in advance
Regards