How do I get the date and time and input it into a field upon success?

How do I get the date and time and input it into a field upon success?

 When user clicks submit, I want the date and time to be inputed into my field, so that data will be shown in view.