In the Memento JavaScript Library (the MJL), you can use the set() method of the Entry object to set the value of a field. See the link to the wiki for this...
Also see the screenshot below.
Now, dates can be a bit tricky to deal with. The basic way dates & times are stored is in milliseconds since Jan 1 1970. However, when creating a Date object, one can create it with other units. See this link for how to do that...
Now, for when to set the field value, you can do this using a Memento action, trigger, or a Button field. See the MJL pages "Actions", "Triggers", and "Trigger Examples" under Scripting in the wiki. I don't recall if the MJL contains info on a Button field or not. Look and see. If not, there might be mention of it in Memento Help, but I doubt it.
Now in the Triggers wiki page, see how to set trigger parameters -- mainly Event and Phase. Before Memento began to offer Prefilled fields, we used to use trigger Event Opening an entry view or entry card for this. You still can do that, and I don't know how to tell you to use prefilled fields.