I’ve found these small functions very useful when trying to pass datetime through Global Variables.
Example:
You can use it to save a value
GlobalVariableSet(name,TimeToDouble(date_time));
and
datetime date_time=DoubleToTime(GlobalVariableGet(name));
when you want to get the value back.