I am ac programmer, I dont have a good knowledge of javascript, I just want to implement a quick feature in googles app script which uses javascript. my question is I am trying to get the date and time from my google site form and on form sumbit I would like to concatenate bookingDate and timeBeg so google calendar will be able to use it as a date and time and book that date on my calendar. How am i able to do this? and a short explanation of the date data type will be appreciated. thank you.
my code below . . .
function onFormSubmit(e)
var bookingDate = new Date();
var endDate = new Date();
var timeBeg = e.values[5];
bookingDate = e.values[3];//the textbox array
endDate = e.values[4];
cal.createEvent("Busy", new Date(bookingDate + time), new Date(endDate), {location:'Nap room'});
Try something like this:
var bookingdatetime = new Date(Date.parse(e.values[3] + " " + e.values[5]));
Naturally it's going to need a bunch of validation before-hand, but that's the gist of it.
By the way, javascript is loosely-typed, so when you assigned bookingDate the value e.values[3], instead of coercing the value into a date, it actually just changes bookingDate into a string, which is probably what you didn't want.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.