AnsweredAssumed Answered

Office 365 Forms - How can I capture the current date and time with a button

Question asked by davidbeayon on Jan 26, 2015
Latest reply on May 15, 2017 by paul.crawford

I have a need to know what the JavaScript methods are for the column type date time.  Specifically I need to be able to set the date and time values via a JavaScript function

Currently I have set up buttons that I want to initializes the date and timestamps for Start and Finish

I have also set the 2 DateTime controls to JavaScript ID's of dtStart and dtFinish.

I can also successfully initialize the JavaScript via the Client Click function of the button.

var start = NWF$("#"+dtStart);
var now = new Date();


When I click the Start button the result is as seen in this screen shot

I can also break down the date values and retrieve them just

var datetime = now.getFullYear()+'/'+(now.getMonth()+1)+'/'+now.getDate(); datetime += ' '+now.getHours()+':'+now.getMinutes()+':'+now.getSeconds();

What I don't know is how to set these values to the dtStart variables for each date and time value.  It doesn't appear that I can set them using the regular JavaScript methods like start.setHours().