<?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[UTC (ISO 8601) in lokale Zeitzone konvertieren]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich bin mal wieder zu blöd und sehe bei google scheinbar den Wald vor lauter Bäumen nicht:</p>
<p>Ich bekomme einen ISO8601-Timestring mit UTC-Zeit (z.B. 2008-08-02T21:57:08.000Z). Diesen möchte ich als 'lokale Zeit' ausgeben also z.B. 02.08.2008 21:57:08.</p>
<p>Die Konvertierung bekomme ich nicht hin. Ich versuche das Ganze ohne .NET oder ähnliches.</p>
<p>Hat jmd einen Tip / eine Lösung?<br />
THX</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/219713/utc-iso-8601-in-lokale-zeitzone-konvertieren</link><generator>RSS for Node</generator><lastBuildDate>Wed, 07 Oct 2026 14:02:43 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/219713.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 06 Aug 2008 16:54:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to UTC (ISO 8601) in lokale Zeitzone konvertieren on Wed, 06 Aug 2008 16:54:43 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich bin mal wieder zu blöd und sehe bei google scheinbar den Wald vor lauter Bäumen nicht:</p>
<p>Ich bekomme einen ISO8601-Timestring mit UTC-Zeit (z.B. 2008-08-02T21:57:08.000Z). Diesen möchte ich als 'lokale Zeit' ausgeben also z.B. 02.08.2008 21:57:08.</p>
<p>Die Konvertierung bekomme ich nicht hin. Ich versuche das Ganze ohne .NET oder ähnliches.</p>
<p>Hat jmd einen Tip / eine Lösung?<br />
THX</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1560358</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1560358</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Wed, 06 Aug 2008 16:54:43 GMT</pubDate></item><item><title><![CDATA[Reply to UTC (ISO 8601) in lokale Zeitzone konvertieren on Wed, 06 Aug 2008 17:34:52 GMT]]></title><description><![CDATA[<p>Du musst diesen String erstmal in einen richtigen Unix-Timestamp parsen.<br />
Mit diesem kannst du dann ganz leicht weiterarbeiten und beispielsweise mit<br />
den Funktionen <a href="http://www.cplusplus.com/reference/clibrary/ctime/localtime.html" rel="nofollow">localtime</a> und <a href="http://www.cplusplus.com/reference/clibrary/ctime/strftime.html" rel="nofollow">strftime</a> das ganze wieder als lokale Zeit ausgeben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1560382</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1560382</guid><dc:creator><![CDATA[JustSomeCoder]]></dc:creator><pubDate>Wed, 06 Aug 2008 17:34:52 GMT</pubDate></item><item><title><![CDATA[Reply to UTC (ISO 8601) in lokale Zeitzone konvertieren on Wed, 06 Aug 2008 19:27:27 GMT]]></title><description><![CDATA[<p>Kannst Du auch noch einen Parser o.ä. empfehlen oder einfach Jahre-1970, Monate etc. in Sekunden umrechnen? Letzteres müßte ja eigentlich gehen, wenn ich immer UTC bekomme.<br />
Für meinen Layout-Fall ist dann ja wohl 'strftime' auch die bessere Variante.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1560440</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1560440</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Wed, 06 Aug 2008 19:27:27 GMT</pubDate></item><item><title><![CDATA[Reply to UTC (ISO 8601) in lokale Zeitzone konvertieren on Thu, 07 Aug 2008 06:58:22 GMT]]></title><description><![CDATA[<p>Ich hab dir mal schnell ein Beispiel geschrieben wie's ich ungefähr machen würde:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;ctime&gt; 
using namespace std;

time_t strToTime(string str)
{
	struct tm timeinfo;
	timeinfo.tm_year = atoi(str.substr(0, 4).c_str()) - 1900;
	timeinfo.tm_mon = atoi(str.substr(5, 2).c_str()) - 1;
	timeinfo.tm_mday = atoi(str.substr(8, 2).c_str());
	timeinfo.tm_hour = atoi(str.substr(11, 2).c_str());
	timeinfo.tm_min = atoi(str.substr(14, 2).c_str());
	timeinfo.tm_sec = atoi(str.substr(17, 2).c_str());

	return mktime(&amp;timeinfo);
}

int main ()
{
	time_t time = strToTime(&quot;2008-08-02T21:57:08.000Z&quot;);
	struct tm *timeinfo = localtime(&amp;time);

	char buffer[80];
	strftime(buffer, 80, &quot;%c&quot;, timeinfo);

	cout &lt;&lt; buffer &lt;&lt; endl;

	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1560568</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1560568</guid><dc:creator><![CDATA[JustSomeCoder]]></dc:creator><pubDate>Thu, 07 Aug 2008 06:58:22 GMT</pubDate></item><item><title><![CDATA[Reply to UTC (ISO 8601) in lokale Zeitzone konvertieren on Thu, 07 Aug 2008 08:10:19 GMT]]></title><description><![CDATA[<p>Wow! Sehr genial. In die Richtung hatte ich auch gedacht und ich verstehe den Code sogar!!<br />
Und ich weiß definitiv, dass ich die -1 beim Monat auch vergessen hätte. Allerdings frage ich mich jetzt, was mit dem Tag ist, da sollte man doch auch einen abziehen, oder nicht? Einen 0. gibt's doch auch da nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1560609</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1560609</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 07 Aug 2008 08:10:19 GMT</pubDate></item><item><title><![CDATA[Reply to UTC (ISO 8601) in lokale Zeitzone konvertieren on Thu, 07 Aug 2008 08:29:33 GMT]]></title><description><![CDATA[<p>Nee beim Tag, also tm_mday, musst du nichts abziehen.<br />
Das liegt daran dass tm_mday die Werte 1-31 haben kann, was ja auch praktisch schon passt.<br />
Beim Monat, tm_mon, ist es jedoch so, dass dieser Wert 0-11 sein kann, wobei 0 eben der Januar ist und 11 der Dezember.<br />
Und vom Jahr tm_year muss man prinzipiell immer die 1900 subtrahieren.</p>
<p>Nachlesen kannst du das ganze auch nochmal in der <a href="http://msdn.microsoft.com/en-us/library/bf12f0hc(VS.71).aspx" rel="nofollow">MSDN</a>.</p>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1560628</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1560628</guid><dc:creator><![CDATA[JustSomeCoder]]></dc:creator><pubDate>Thu, 07 Aug 2008 08:29:33 GMT</pubDate></item><item><title><![CDATA[Reply to UTC (ISO 8601) in lokale Zeitzone konvertieren on Thu, 07 Aug 2008 10:59:13 GMT]]></title><description><![CDATA[<p>Ja, ich hatte da wohl auch einen Denkfehler drin.<br />
Aber spätestens mit dem Blick in die Doku ist das jetzt klar.</p>
<p>Dank Dir!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1560766</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1560766</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 07 Aug 2008 10:59:13 GMT</pubDate></item><item><title><![CDATA[Reply to UTC (ISO 8601) in lokale Zeitzone konvertieren on Thu, 07 Aug 2008 19:04:19 GMT]]></title><description><![CDATA[<p>Hmm, schade:<br />
Ich bekomme am Ende wieder GMT raus. Muss man vorm 'localtime' noch etwas machen, damit wirklich die Zeitzonen bedacht werden?<br />
Habe 2 Stunden Abweichung (+1 Deutschland und +1 Sommerzeit).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1561068</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1561068</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 07 Aug 2008 19:04:19 GMT</pubDate></item><item><title><![CDATA[Reply to UTC (ISO 8601) in lokale Zeitzone konvertieren on Thu, 07 Aug 2008 19:11:24 GMT]]></title><description><![CDATA[<p><a href="http://www.c-plusplus.net/forum/viewtopic-var-p-is-1540082.html#1540082" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-p-is-1540082.html#1540082</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1561073</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1561073</guid><dc:creator><![CDATA[lächeln]]></dc:creator><pubDate>Thu, 07 Aug 2008 19:11:24 GMT</pubDate></item><item><title><![CDATA[Reply to UTC (ISO 8601) in lokale Zeitzone konvertieren on Thu, 07 Aug 2008 20:21:36 GMT]]></title><description><![CDATA[<p>Versuchs mal mit der Funktion <em>gmtime</em> anstelle von <em>localtime</em>,<br />
da ja alles andere auch irgendwie rückwärts gemacht werden musste.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1561117</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1561117</guid><dc:creator><![CDATA[JustSomeCoder]]></dc:creator><pubDate>Thu, 07 Aug 2008 20:21:36 GMT</pubDate></item><item><title><![CDATA[Reply to UTC (ISO 8601) in lokale Zeitzone konvertieren on Fri, 08 Aug 2008 06:56:26 GMT]]></title><description><![CDATA[<p>...oder erst mal lesen, ich war gestern nicht wirklich bei der Sache:</p>
<p>- MSDN:</p>
<blockquote>
<p>localtime corrects for the local time zone if the user first sets the global environment variable TZ. When TZ is set, three other environment variables (_timezone, _daylight, and _tzname) are automatically set as well. If the TZ variable is not set, localtime attempts to use the time zone information specified in the Date/Time application in Control Panel. If this information cannot be obtained, PST8PDT, which signifies the Pacific time zone, is used by default. See _tzset for a description of these variables. TZ is a Microsoft extension and not part of the ANSI standard definition of localtime.</p>
</blockquote>
<p>...Oh Mist, Umgebungsvariable hört sich nicht praktikabel an.<br />
- @lächeln: Weiß noch nicht ganz, was Du mir sagen willst, aber das finde ich schon noch heraus<br />
- kann das im Moment leider nicht testen, werde das aber heute nachmittag (hoffentlich wacher) machen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1561226</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1561226</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Fri, 08 Aug 2008 06:56:26 GMT</pubDate></item><item><title><![CDATA[Reply to UTC (ISO 8601) in lokale Zeitzone konvertieren on Fri, 08 Aug 2008 07:40:10 GMT]]></title><description><![CDATA[<p>Boost's Date/Time hat sowas iirc eingebaut, ist sicherer/einfacher als selber schreiben:</p>
<p><a href="http://www.boost.org/doc/libs/1_35_0/doc/html/date_time.html" rel="nofollow">http://www.boost.org/doc/libs/1_35_0/doc/html/date_time.html</a></p>
<p>solltest du mit &quot;ohne .NET oder sowas&quot; gemeint haben &quot;ohne externe Bibliotheken&quot;, dann bedenke, dass boost qausi ein erweiterter C++ Standard ist <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1561254</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1561254</guid><dc:creator><![CDATA[Blue-Tiger]]></dc:creator><pubDate>Fri, 08 Aug 2008 07:40:10 GMT</pubDate></item><item><title><![CDATA[Reply to UTC (ISO 8601) in lokale Zeitzone konvertieren on Fri, 08 Aug 2008 08:39:36 GMT]]></title><description><![CDATA[<p>Sehe ich mir auch mal an.<br />
Mit dem .NET.... meinte ich, dass ich keine weiteren Installationen auf dem Anwenderrechner voraussetzen möchte.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1561282</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1561282</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Fri, 08 Aug 2008 08:39:36 GMT</pubDate></item><item><title><![CDATA[Reply to UTC (ISO 8601) in lokale Zeitzone konvertieren on Sun, 10 Aug 2008 17:34:25 GMT]]></title><description><![CDATA[<p>So, ich habe das jetzt mit den 'alten' Hausmitteln hinbekommen. Hatte mir das einfacher vorgestellt, aber so sollte es gehen:</p>
<pre><code>string l_endzeit(&quot;2008-08-02T21:57:08.000Z&quot;);
_tzset();

long l_timezone;
_get_timezone(&amp;l_timezone);

struct tm timeinfoInput;
timeinfoInput.tm_year = atoi(l_endzeit.substr(0, 4).c_str()) - 1900;
timeinfoInput.tm_mon = atoi(l_endzeit.substr(5, 2).c_str()) - 1;
timeinfoInput.tm_mday = atoi(l_endzeit.substr(8, 2).c_str());
timeinfoInput.tm_hour = atoi(l_endzeit.substr(11, 2).c_str());
timeinfoInput.tm_min = atoi(l_endzeit.substr(14, 2).c_str());

// mktime macht die Zeitzonen-Anpassung, timeinfoInput ist aber schon gmt 
// und sollte nicht angepasst werden, also abziehen
timeinfoInput.tm_sec = atoi(l_endzeit.substr(17, 2).c_str()) - l_timezone;
timeinfoInput.tm_isdst = 0; // Wir wollen GMT erstellen!

time_t time = mktime(&amp;timeinfoInput);
struct tm timeinfoOutput = *(localtime(&amp;time));
....
timeinfoOutput funzt
</code></pre>
<p>(Falls es jemanden interessiert.) <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1562324</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1562324</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 10 Aug 2008 17:34:25 GMT</pubDate></item></channel></rss>