Answer
Check the exact string format your script produces against what the workflow's date-time conversion actually expects — a JavaScript Date's default string output isn't automatically in a workflow-supported date-time format, so explicitly reformatting it (for example, from an ISO-style timestamp into the specific format the target API field expects) before passing it into the API call is usually the fix, not the underlying date value itself being wrong.