Answer
The workflow engine only accepts a couple of specific DATETIME string formats, and neither a raw JavaScript Date object nor its default ISO-string output matches them — format the value explicitly (for example, using Java's SimpleDateFormat from a script task to produce a yyyy-MM-dd-HH.mm.ss-style string) before setting it as the execution variable feeding the custom attribute. See the workflow engine's directly-supported date/datetime formats.