Extends JavaScript Date Object for Adobe Acrobat

Methods

changeBy

(
  • oChange
)
Date

Modifies this Date instance by the change specified in the object passed

Parameters:

Parameter
Type
Description
oChange
Object

The object can have as many properties set as required. Negative numbers indicate the past.

Property
Type
Description
milliseconds
Number
(optional) 

milliseconds to change this Date instance by

seconds
Number
(optional) 

seconds to change this Date instance by

minutes
Number
(optional) 

minutes to change this Date instance by

hours
Number
(optional) 

hours to change this Date instance by

days
Number
(optional) 

days to change this Date instance by

weeks
Number
(optional) 

weeks to change this Date instance by

months
Number
(optional) 

months to change this Date instance by

years
Number
(optional) 

years to change this Date instance by

Returns:

:

The modified Date object

Example:

today = new Date(); var change = {     "years":3,     "days":2,     "hours":6 }; today.changeBy(change); event.value = today.toFormattedString(Date.SORTABLE_DATETIME);

changeByDays

(
  • days
)
Date

Adds or subtracts days from this Date instance

Parameters:

Parameter
Type
Description
days
Number

The parameter can be positive or negative. Negative numbers go into the past.

Returns:

:

The adjusted Date instance

changeByHours

(
  • hours
)
Date

Adds or subtracts hours from this Date instance

Parameters:

Parameter
Type
Description
hours
Number

The parameter can be positive or negative. Negative numbers go into the past.

Returns:

:

The adjusted Date instance

changeByMilliseconds

(
  • milliseconds
)
Date

Adds or subtracts milliseconds from this Date instance

Parameters:

Parameter
Type
Description
milliseconds
Number

The parameter can be positive or negative. Negative numbers go into the past.

Returns:

:

The adjusted Date instance

changeByMinutes

(
  • minutes
)
Date

Adds or subtracts minutes from this Date instance

Parameters:

Parameter
Type
Description
minutes
Number

The parameter can be positive or negative. Negative numbers go into the past.

Returns:

:

The adjusted Date instance

changeByMonths

(
  • months
)
Date

Adds or months days from this Date instance

Parameters:

Parameter
Type
Description
months
Number

The parameter can be positive or negative. Negative numbers go into the past.

Returns:

:

The adjusted Date instance

changeBySeconds

(
  • seconds
)
Date

Adds or subtracts seconds from this Date instance

Parameters:

Parameter
Type
Description
seconds
Number

The parameter can be positive or negative. Negative numbers go into the past.

Returns:

:

The adjusted Date instance

changeByWeeks

(
  • weeks
)
Date

Adds or weeks days from this Date instance

Parameters:

Parameter
Type
Description
weeks
Number

The parameter can be positive or negative. Negative numbers go into the past.

Returns:

:

The adjusted Date instance

changeByYears

(
  • years
)
Date

Adds or years days from this Date instance

Parameters:

Parameter
Type
Description
years
Number

The parameter can be positive or negative. Negative numbers go into the past.

Returns:

:

The adjusted Date instance

daysBetween

(
  • aDate
  • anotherDate
)
Number

Returns the number of days between two Date instances.

Parameters:

Parameter
Type
Description
aDate
Date
anotherDate
Date

Returns:

Number
:

The value will always be positive.

getAge

(
  • dateOfBirth
)
Number static

Returns the number of years between today and the Date instance passed.

Parameters:

Parameter
Type
Description
dateOfBirth
Date

Returns:

Number

getAgeFromString

(
  • dateOfBirth
  • [format]
)
Number static

Returns the number of years between today and the Date instance passed.

Parameters:

Parameter
Type
Description
dateOfBirth
String

Date of Birth

format
String
(optional) 

Returns:

Number

getDayName

(
  • [bShort]
)
String

Returns the day of the week for this Date instance

Parameters:

Parameter
Type
Description
bShort
Boolean
(optional) 

Return the three letter name

Returns:

String
:

The name of the week

getDayOfYear

() Number

Gets the numeric day of the year

Returns:

Number
:

Returns a Number corresponding to the number of days since the beginning of the year

getDaysInMonth

(
  • nYear
  • nMonth
)
Number static

Gets the number of days in the month, given a year and month . Automatically corrects for LeapYear.

Parameters:

Parameter
Type
Description
nYear
Number

4 digit year

nMonth
Number

January = 0. December = 11)

Returns:

Number
:

The number of days in the month.

getMonthName

(
  • [bShort]
)
String

Returns the month name or this Date instance

Parameters:

Parameter
Type
Description
bShort
Boolean
(optional) 

Return the three letter name

Returns:

String
:

The name of the month

getWeekOfYear

(
  • nWeekStartDay
)
Number

Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. The .getWeek() function does NOT convert the date to UTC. The local datetime is used.

Parameters:

Parameter
Type
Description
nWeekStartDay
Number

1 or 0 depending on first day of the week. Sunday = 0, Monday = 1

Returns:

Number
:

1 to 53

isLeapYear

(
  • year
)
Boolean static

Determines if the current date instance is within a LeapYear.

Parameters:

Parameter
Type
Description
year
Number

Returns:

Boolean
:

true if date is within a LeapYear, otherwise false.

Example:

var leapYear = Date.isLeapYear(2016);

max

(
  • dates
)
Date static

Returns the latest of the given Date instances

Parameters:

Parameter
Type
Description
dates
Array

An array of Date instances

Returns:

Example:

// Custom calculation for an Acrobat Text field var dates = [ ]; dates.push( new Date( "1956/08/05" ) ); dates.push( new Date( "1960/12/19" ) ); dates.push( new Date( "1961/08/14" ) ); dates.push( new Date( "1958/04/29" ) ); dates.push( new Date( "1954/09/30" ) ); dates.push( new Date( "1957/11/07" ) ); var youngestSibling = Date.max(dates); event.value = youngestSibling.toFormattedString( Date.SHORT_DATE )

millisecondsElapsed

(
  • Defaults
)
Number

Returns the number of milliseconds between this Date instance and the date parameter.

Parameters:

Parameter
Type
Description
Defaults
[Date]

to now

Returns:

Number
:

The difference in milliseconds. Return value will always be positive.

min

(
  • dates
)
Date static

Returns the earliest of the given Date instances

Parameters:

Parameter
Type
Description
dates
Array

An array of Date instances

Returns:

Example:

// Custom calculation for an Acrobat Text field var dates = [ ]; dates.push( new Date( "1956/08/05" ) ); dates.push( new Date( "1960/12/19" ) ); dates.push( new Date( "1961/08/14" ) ); dates.push( new Date( "1958/04/29" ) ); dates.push( new Date( "1954/09/30" ) ); dates.push( new Date( "1957/11/07" ) ); var oldestSibling = Date.min(dates); event.value = oldestSibling.toFormattedString( Date.SHORT_DATE )

nextMonth

() Date

Sets the date of this Date instance to the first day of the following month.

Returns:

:

The first day of the following month. If true is passed as the parameter, the first business day. Business days being Monday through Friday.

nextWeekDay

() Date

Sets the date of this Date instance to the following weekday. Weekdays being Monday through Friday

Returns:

:

The following day if the current date is Monday through Thursday. Returns the coming Monday if the current day is Friday through Sunday.

Example:

d = new Date().nextWeekDay(); event.value = d.toFormattedString(Date.LONG_DATE);

reset

() Date

Resets the time of this Date object.

Returns:

:

Date object for the same day but with time set to 12:00 AM (00:00), which is the start of the day.

toFormattedString

(
  • cFormat
)
String

Format this Date instance to a string

Parameters:

Parameter
Type
Description
cFormat
String

The format you want the string to match

Returns:

String

Example:

var d = new Date(); var myString = d.toFormattedString(Date.YEAR_MONTH);

Properties

FULL_DATETIME

String

The time format "dddd, mmmm dd, yyyy h:MM:ss tt"

"tt" indicates am/pm

Example:

var d = new Date(); var myString = d.toFormattedString(Date.FULL_DATETIME);

LONG_DATE

String

The date format "dddd, mmmm, dd, yyyy"

Example:

var d = new Date(); var myString = d.toFormattedString(Date.LONG_DATE);

LONG_TIME

String

The time format "h:MM:ss tt
"tt" indicates am/pm

Example:

var d = new Date(); var myString = d.toFormattedString(Date.LONG_TIME);

MONTH_DAY

String

The time format "mmmm dd"

Example:

var d = new Date(); var myString = d.toFormattedString(Date.MONTH_DAY);

PPDF_VERSION

String

The version of this API

SHORT_DATE

String

The date format "m/d/yyyy"

Example:

var d = new Date(); var myString = d.toFormattedString(Date.SHORT_DATE);

SHORT_TIME

String

The time format "h:MM tt"
"tt" indicates am/pm

Example:

var d = new Date(); var myString = d.toFormattedString(Date.SHORT_TIME);

SORTABLE_DATETIME

String

The time format "yyyy-mm-dd HH:MM:ss"

Example:

var d = new Date(); var myString = d.toFormattedString(Date.FULL_DATETIME);

YEAR_MONTH

String

The time format "yyyy mmmm"

Example:

var d = new Date(); var myString = d.toFormattedString(Date.YEAR_MONTH);