Skip to main content
Participant
October 2, 2021
Question

Milliseconds to Formatted Date

  • October 2, 2021
  • 1 reply
  • 323 views

I'm creating an Adobe form. Based on the data input in one field, I want to automatically update dates in other read-only fields -- some adding 1 o rmore days, some subtracting 1 or more days.

 

I have converted the input date string into milliseconds and added (and subtracted) the milliseconds to get to the other dates I want.  How do I format the new milliseconds to MM/DD/YYYY format when they display in the other fields I'm pushing the new dates into? (i.e., user inputs 09/30/2021 and I push 10/01/2021 into other, read only, fields on the form)

 

Here's the code I have so far:

if(event.value) {
this.getField("Date Test Output").value = Date.parse(event.value)+86400000
}

This topic has been closed for replies.

1 reply

Nesa Nurani
Community Expert
Community Expert
October 2, 2021

Use this and change number of days to + or - (Number of days are marked red):

if(event.value == "")
this.getField("Date Test Output").value = "";
else{
var days = util.scand("mm/dd/yyyy", event.value)
days.setDate(days.getDate() +1);
this.getField("Date Test Output").value = util.printd("mm/dd/yyyy", days);}