What already works
I am using \immediate\write18 to let the GNU date command do some date/time arithmetic. The resulting timestamp in ISO format (e.g., 2011-09-09T09:59:59Z) is written to a temporary file /tmp/date.txt, whose content is then read into the macro \ScriptResult, which I can happily print. So far so good.
What doesn't work yet
I am then trying to use \DTMsavetimestamp from the datetime2 package to save \ScriptResult to a timestamp that I can print via \DTMusedate and \DTMusetime (both also part of datetime2). However, this breaks compilation.
I have absolutely zero doubts that this is due to some expansion-related problem. :)
Minimal (non-)working example
Save the following file to test.tex and try to compile via pdflatex -shell-escape test.tex (-shell-escape crucial due to \write18). Compilation will fail. You can then try to comment the line \DTMsavetimestamp{mytimestamp}{\ScriptResult} and uncomment the line \DTMsavetimestamp{mytimestamp}{2011-09-09T09:59:59Z}, after which the MWE compiles fine. This is what makes me think that this issue relates to expansion.
% NOTE: Compile via: pdflatex -shell-escape
\documentclass{article}
\usepackage{datetime2}
\begin{document}
\def\mydate{2015-01-01}%
\def\mytime{12:23}%
\def\offset{-7}
% Black magic that works just fine and we should not have to worry about
\immediate\write18{echo '\mydate\space\mytime\space\offset hours' | sed -e 's/://' | xargs -0 date +\%Y-\%m-\%dT\%H:\%M:\%SZ -d > /tmp/date.txt}%
% Write temporary file content to \ScriptResult. NOTE: Works
% Inspired from: http://tex.stackexchange.com/a/251574/38212
\newread\myscriptresult
\immediate\openin\myscriptresult=/tmp/date.txt
\read\myscriptresult to \ScriptResult
\immediate\closein\myscriptresult
% Print \ScriptResult. NOTE: Works
\noindent Return value read from \verb|/tmp/date.txt|: \ScriptResult\\
\DTMsavetimestamp{mytimestamp}{\ScriptResult}% TODO: This breaks compilation...
%\DTMsavetimestamp{mytimestamp}{2011-09-09T09:59:59Z}% ... whereas this works.
\noindent Date: \DTMusedate{mytimestamp}\\
\noindent Time: \DTMusetime{mytimestamp}
\end{document}
Restrictions
I am looking for a solution that continues to use the datetime2 package. If there is a solution that does not require writing to a temporary file /tmp/date.txt, that would actually be welcome (but it's not a priority).

HH:MM:SS. – Werner Jul 20 '16 at 16:47\write18command takes care of the "missing second" and outputs an ISO-formatted timestamp, based on the given date, time, and\offset, which is interpreted as an offset in hours (that's the date/time arithmetic bit). However, this part works like a charm and should not even have to be understood in detail to solve this problem. – Florian H. Jul 20 '16 at 17:03\begingroup\edef\x{\endgroup\noexpand\DTMsavetimestamp{\ScriptResult}}\x. – Werner Jul 20 '16 at 17:04\offsetadds or subtracts a given number of hours to the timestamp defined by\mydateand\mytime. That's why I need GNU date. Your first solution above bypasses GNU date (and hence the ability to compute the offset). Your second solution gives me aRunaway argument? ! Paragraph ended before \DTMsavetimestamp was complete.– Florian H. Jul 20 '16 at 17:06