Copy link to clipboard
Copied
i use this : event.target.value = util.printd("dd/mm/yyyy",this.creationDate); to add automatically system date to a fill form... now how i check if date is Sat or Sun? and how to check if month is Jun July or Aug?
Copy link to clipboard
Copied
You can use the mm value to check the month number.
var monthnumber = util.printd("mm",this.creationDate)
may give you an idea how o work with it.
The documentation of util.printd shows you can get the day name too. You can work with that if your form will only be used by English speakers. It's a pity it doesn't return day-of-the-week-number because that would be independent of language.
Copy link to clipboard
Copied
this.creationDate.getDay(); // returns day of the week
Copy link to clipboard
Copied
The returned value will be a number 0-6 with Sunday being 0 and Saturday being 6.
One can also use the util.printd to extract the date as a 3 letter code or the full name of the day.
Copy link to clipboard
Copied
Using MDN JavaScript:
Day of the week:
this.creationDate.getDay()
Will return the day of the week as a number with Sunday being 0 and Saturday is 6.
The month can be obtained using the getMonth method.
this.creationDate.getMonth()
Returning 0 for January and 11 for December.
Using the Acrobat util.printd method:
Day of the week:
Three character day: util.printd("ddd", this.creationDate)
Full day name util.printd("dddd", this.creationDate)
Three digit month:util.printd("mmm", this.creationDate)
Full monthname util.printd("mmmm", this.creationDate)
One can even create a user function to tell if the day of the week is a weekend:
function isWeekend(oDate) {
// return true if date object date is a weekend,
// otherwise return fals;
var bWeekend = false;
if(oDate.getDay() == 0 || oDate.getDay == 7) {
// date is Sunday or Saturday;
bWeekend = true;
}
return bWeekend;
}
Usage:
isWeekend(this.creationDate);