Chris's Wiki :: blog/unix/GNUDateAndRFC3339 Commentshttps://utcc.utoronto.ca/~cks/space/blog/unix/GNUDateAndRFC3339?atomcommentsDWiki2022-07-19T02:02:12ZRecent comments in Chris's Wiki :: blog/unix/GNUDateAndRFC3339.By Simon on /blog/unix/GNUDateAndRFC3339tag:CSpace:blog/unix/GNUDateAndRFC3339:4aadeec53786544a9c4e00d2e714dc82e20af474Simon<div class="wikitext"><blockquote><p>Since the standard formatting of strftime() has no option for a '[+-]hh:mm' version of the time zone offset (only a version without the separator, as '%z'), you cannot use them to produce RFC 3339 dates in local time.</p>
</blockquote>
<p>FWIW: GNU date supports %:z for this (Not helpful in your case, but can be in other cases).</p>
</div>2022-07-19T02:02:12ZBy Chris Siebenmann on /blog/unix/GNUDateAndRFC3339tag:CSpace:blog/unix/GNUDateAndRFC3339:a9d29d3ecb147b13b05c4444b7569dba588c959eChris Siebenmann<div class="wikitext"><p>Unfortunately, versions of <code>date</code> where you might need to use the
format string also don't support '<code>--rfc-3339</code>' or any equivalent
of it. Only GNU Date currently supports that and it also supports
'<code>--iso8601=seconds</code>' so you can skip all of the complexity and
directly get what you want.</p>
</div>2021-01-11T05:48:20ZBy Matt S Trout (mst) on /blog/unix/GNUDateAndRFC3339tag:CSpace:blog/unix/GNUDateAndRFC3339:445a2816e217ab1159efe9c32f62ed79d7009645Matt S Trout (mst)http://shadow.cat/blog/matt-s-trout/<div class="wikitext"><p>Honestly, this is where I'd do:</p>
<pre>
datestr=$(date --rfc-3339=seconds | tr ' ' T);
</pre>
<p>since I'd find that easier to read later than the full format string.</p>
</div>2021-01-11T05:34:42Z