• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

check if date is weekend ADOBE DC

Explorer ,
Oct 07, 2018 Oct 07, 2018

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?

TOPICS
Acrobat SDK and JavaScript

Views

158

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 07, 2018 Oct 07, 2018

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 07, 2018 Oct 07, 2018

Copy link to clipboard

Copied

this.creationDate.getDay();  // returns day of the week

JavaScript Date Reference

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 07, 2018 Oct 07, 2018

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 08, 2018 Oct 08, 2018

Copy link to clipboard

Copied

LATEST

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);

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines