![]() |
[Sailfish] Unix timestamp from XML file to string
Hi,
I am very new to Qt and just got stuck at a probably very simple problem. The XML file I got contains a date formatted as unix timestamp. How do I get this timestamp into a string? This is XmlRole: Code:
XmlRole { name: "date"; query: "date/number()" } Code:
Label { Thanks! |
Re: [Sailfish] Unix timestamp from XML file to string
1. you declaring "date" role, but using "datum". wtf?
2. show your xml |
Re: [Sailfish] Unix timestamp from XML file to string
Quote:
[Update] After a lot of try and error I found the mistake. Date alone was not enough, I had to create a new Date and multiply with 1000 since JavaScript expects milliseconds. Now the code works but I get UTC time. I deducted one hour but I guess that is not the correct way to do it. In case anybody knows how to do it correctly please let me know. Code:
Label { |
Re:[Sailfish] Unix timestamp from XML file to string
After I deployed the app to my Jolla the time zone was correct but on some dates the time is off by -1 Minute.
So I guess this is still not the correct way to do it. Can anyone tell me what is the right way to format a unix timestamp? Code:
Qt.formatDateTime( new Date(model.date*1000),"dd.mm.YY - hh:mm" ) |
Re: [Sailfish] Unix timestamp from XML file to string
show me timestamp showing not correctly
|
Re: [Sailfish] Unix timestamp from XML file to string
This is the timestamp: 1391187600
And the Result is: 31.01.2014 - 17.59 |
Re: [Sailfish] Unix timestamp from XML file to string
1397232000 on the other side gives the intended time. I tried to add some milliseconds but this doesn't help either...
|
Re: [Sailfish] Unix timestamp from XML file to string
its impossible.
new Date(1391187600 * 1000).toString(); showing Fri Jan 31 2014 23:00:00 GMT+0600 (YEKT) |
Re: [Sailfish] Unix timestamp from XML file to string
It is displayed correctly on the emulator. I only have the offset on my phone. Mybe it is a bug...
|
Re: [Sailfish] Unix timestamp from XML file to string
i'm not using emulator
|
All times are GMT. The time now is 15:24. |
vBulletin® Version 3.8.8