I need to prompt the user to select beginning and end dates for calendar entry. How do I do this using “addDatePicker” command. Any documentation on this ? I would appreciate a simple example script :
displaying date picker
and creating two variables containing “begin date” and an “end date” after selection has been made by user.
This expands on the information highlighted by @RosemaryOrchard.
var p = Prompt.create();
p.title = "Date Selection";
p.addDatePicker("dateBegin", "Begin date", new Date(), {
"mode": "date"
});
p.addDatePicker("dateEnd", "End date", new Date(), {
"mode": "date"
});
p.addButton("OK");
if (p.show())
{
if (p.buttonPressed == "OK")
{
alert("Begin date is " + p.fieldValues["dateBegin"] + "\nEnd Date is " + p.fieldValues["dateEnd"]);
}
}
When run you may see that you are getting full time stamps and not a simple date back. As a result you may want to do some manipiulation of the dates as they stand to remove the time (and maybe(?) the time zone) … assuming you get the sort of result I get.
But that’s a slightly different question and the sort of thing you will probably need to work with in order to do whatever you want to do next with the dates captured.
Yes you were right I would be grateful if you could show me how to format the date output without time zone and 24 hr time format - hours and minutes only. Thanks v much.