View Full Version : QDateTime GMT add sec. or - sec. from locale time....

20th February 2007, 15:06
The server send my a date format evry time on GMT null format... Greenw...
"Wed, 07 Feb 2007 18:44:19 GMT"
to append one one H i make so...
dateTime2.addSecs(3600); /* by hand ....*/
but how i can discovery a calculable local date.... +1 or -1

muss i build a switsch for evry 24 world H. time....

I like Unix time format to display human readable time and to see diff from localfile lastmod time.... (QFileInfo)

/* grab remote server gmt time to check localfile lastmod update or not */

uint MailTimeString( QString indate )


/* incomming format Wed, 07 Feb 2007 18:44:19 GMT*/

/* or mail rtf Date format! http://www.faqs.org/rfcs/rfc788.html */



QLocale::setDefault(QLocale::C); /* on comment out time is bad */

QStringList sdate = indate.split(" ");

if (sdate.size() != 6) {

return QTime_Null(); /* time current uint format */




QString reformat = sdate.join(" ");

QDateTime dateTime2 = QDateTime::fromString(reformat,"dd MMM yyyy HH:mm:ss");

QDateTime dateTime3 = dateTime2.addSecs(3600); /* GMT +1 switzerland */

QLocale::system(); /* on comment out time is bad */

return dateTime3.toTime_t();


20th February 2007, 16:55
I must admit that I have not 100% understood you question.

But If you would like to convert a GMT datetime to a local datetime:

QDateTime gmtDateTime = parseDateTime(XXXXX);
QDateTime localDateTime = gmtDateTime.toLocalTime();

20th February 2007, 17:39
Oh.... yes only this simple "Qt::UTC" && .toLocalTime(); solve the date problem.... Tanks... :)