<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[SOLVED] Unable to convert string to int to perform MSecsSinceEpoch]]></title><description><![CDATA[<p dir="auto">Hello people!</p>
<pre><code>      I'm trying to convert a string into a date time format in the following way
</code></pre>
<p dir="auto">@<br />
QDateTime timestamp;<br />
timestamp.setMSecsSinceEpoch(1350977160000);<br />
qDebug()&lt;&lt; timestamp.toString(Qt::SystemLocaleLongDate);<br />
@</p>
<p dir="auto">This works well and gives me the correct output as <em>Tuesday, 23 October, 2012 12:56:00 PM</em><br />
However, when I store <em>1350977160000</em> into a QString and then try to convert it to <em>int</em> , it doesn't seem to give the correct output. Instead, I get <em>Tuesday, 05 February, 2013 5:30:00 AM</em></p>
<p dir="auto">@<br />
QDateTime timestamp;<br />
QString s = "1350977160000";</p>
<pre><code>bool ok;

quint64 dateTime = s.toLong(&amp;ok,10);
timestamp.setMSecsSinceEpoch(dateTime);

qDebug()&lt;&lt; timestamp.toString(Qt::SystemLocaleLongDate);
</code></pre>
<p dir="auto">@</p>
<p dir="auto">Please help me. Where am I going wrong?<br />
Thanks.</p>
]]></description><link>https://forum.qt.io/topic/23954/solved-unable-to-convert-string-to-int-to-perform-msecssinceepoch</link><generator>RSS for Node</generator><lastBuildDate>Mon, 10 Aug 2026 01:05:53 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/23954.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 05 Feb 2013 05:09:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [SOLVED] Unable to convert string to int to perform MSecsSinceEpoch on Tue, 05 Feb 2013 06:49:15 GMT]]></title><description><![CDATA[<p dir="auto">Your Welcome.. :)</p>
<p dir="auto">[quote author="holygirl" date="1360042606"]@<br />
I swear to God I tried this before but it didn't work. But it is now. [/quote]</p>
<p dir="auto">True... Sometimes it happens.... :)</p>
]]></description><link>https://forum.qt.io/post/165904</link><guid isPermaLink="true">https://forum.qt.io/post/165904</guid><dc:creator><![CDATA[Macro]]></dc:creator><pubDate>Tue, 05 Feb 2013 06:49:15 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] Unable to convert string to int to perform MSecsSinceEpoch on Tue, 05 Feb 2013 05:36:46 GMT]]></title><description><![CDATA[<p dir="auto">@<br />
double dateTime = s.toDouble();<br />
@</p>
<p dir="auto">This worked! I swear to God I tried this before but it didn't work. But it is now. Grrrr! Such a silly thing. Thank you very much Rochi :)</p>
]]></description><link>https://forum.qt.io/post/165901</link><guid isPermaLink="true">https://forum.qt.io/post/165901</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Tue, 05 Feb 2013 05:36:46 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] Unable to convert string to int to perform MSecsSinceEpoch on Tue, 05 Feb 2013 05:30:26 GMT]]></title><description><![CDATA[<p dir="auto">Try this,</p>
<p dir="auto">@quint64 dateTime = Q_UINT64_C(1350977160000);@</p>
<p dir="auto">or</p>
<p dir="auto">Change this<br />
@quint64 dateTime = s.toLong(&amp;ok,10);@</p>
<p dir="auto">to</p>
<p dir="auto">@double dateTime = s.toDouble();@</p>
<p dir="auto">Hope it should work... :)</p>
]]></description><link>https://forum.qt.io/post/165900</link><guid isPermaLink="true">https://forum.qt.io/post/165900</guid><dc:creator><![CDATA[Macro]]></dc:creator><pubDate>Tue, 05 Feb 2013 05:30:26 GMT</pubDate></item></channel></rss>