Date
Updated on Aug 9, 2023 5 minutes to readTo utilize the methods offered by this plugin, you should call them through the E8App.$date object.
Add days to a date
Syntax:
E8App.$date.addDays(<value>, <days>)
Description:
Modifies the date adding/subtracting the number of days.
Parameters:
<value> - required
Type: String
Date in 'YYYY-MM-DD' format.
<days> - required
Type: Number
The number of days should be added to a date. If negative – days are subtracted from a date.
Returned value:
The modified date.
Type: String
E8App.$date.addDays('2021-10-21', 10);
Add months to a date
Syntax:
E8App.$date.addMonths(<value>, <months>)
Description:
Adds/subtracts a date interval (in months) to a date.
Parameters:
<value> - required
Type: String
Date in 'YYYY-MM-DD' format.
<months> - required
Type: Number
The number of months should be added to a date. If negative – months are subtracted from a date.
Returned value:
The modified date.
Type: String
E8App.$date.addMonths('2019-09-21', 5);
Add quarters to a date
Syntax:
E8App.$date.addQuarters(<value>, <quarters>)
Description:
Modifies the date adding/subtracting the number of quarters.
Parameters:
<value> - required
Type: String
Date in 'YYYY-MM-DD' format.
<quarters> - required
Type: Number
The number of quarters to add to a date. If negative – quarters are subtracted from a date.
Returned value:
The modified date.
Type: String
E8App.$date.addQuarters('2019-05-18', 2);
Add weeks to a date
Syntax:
E8App.$date.addWeeks(<value>, <weeks>)
Description:
Adds/subtracts a date interval (in weeks) to a date.
Parameters:
<value> - required
Type: String
Date in 'YYYY-MM-DD' format.
<weeks> - required
Type: Number
The number of weeks to add to a date. If negative – weeks are subtracted from a date.
Returned value:
The modified date.
Type: String
E8App.$date.addWeeks('2018-10-25', 3);
Add years to a date
Syntax:
E8App.$date.addYears(<value>, <years>)
Description:
Modifies the date adding/subtracting the number of years.
Parameters:
<value> - required
Type: String
Date in 'YYYY-MM-DD' format.
<years> - required
Type: Number
The number of years should be added to a date. If negative – years are subtracted from a date.
Returned value:
The modified date.
Type: String
E8App.$date.addYears('2019-11-06', 3);
Get current date
Syntax:
E8App.$date.current()
Description:
Get the current date.
Returned value:
The current date in 'YYYY-MM-DD' format.
Type: String
E8App.$date.current();
Get day
Syntax:
E8App.$date.day(<value>)
Description:
Returns the day of month for a date.
Parameters:
<value> - required
Type: String
Date in 'YYYY-MM-DD' format.
Returned value:
The day of month.
Type: Number
E8App.$date.day('1999-11-13');
Get date difference
Syntax:
E8App.$date.diff(<value1>, <value2>)
Description:
Calculates the difference between two dates.
Parameters:
<value1> - required
Type: String
Date in 'YYYY-MM-DD' format.
<value2> - required
Type: String
Date in 'YYYY-MM-DD' format.
Returned value:
The difference between two date values (in days).
Type: Number
E8App.$date.diff('2023-10-31', '2018-10-13');
Get the end of month
Syntax:
E8App.$date.endOfMonth(<value>)
Description:
Returns the date containing the last day of month of a given date.
Parameters:
<value> - required
Type: String
Date in 'YYYY-MM-DD' format.
Returned value:
The date of the last day of month of a given date.
Type: String
E8App.$date.endOfMonth('1997-07-29');
Get the end of quarter
Syntax:
E8App.$date.endOfQuarter(<value>)
Description:
Returns the date containing the last day of quarter of a given date.
Parameters:
<value> - required
Type: String
Date in 'YYYY-MM-DD' format.
Returned value:
The date of the last day of quarter of a given date.
Type: String
E8App.$date.endOfQuarter('1980-01-25');
Get the end of week
Syntax:
E8App.$date.endOfWeek(<value>)
Description:
Returns the date containing the last day of week of a given date.
Parameters:
<value> - required
Type: String
Date in 'YYYY-MM-DD' format.
Returned value:
The date of the last day of week of a given date.
Type: String
E8App.$date.endOfWeek('2022-11-12');
Get the end of year
Syntax:
E8App.$date.endOfYear(<value>)
Description:
Returns the date containing the last day of year of a given date.
Parameters:
<value> - required
Type: String
Date in 'YYYY-MM-DD' format.
Returned value:
The date of the last day of year of a given date.
Type: String
E8App.$date.endOfYear('2023-10-16');
Check the validity of date
Syntax:
E8App.$date.isValid(<value>)
Description:
Check if a given value is a valid date.
Parameters:
<value> - required
Type: String
Date in 'YYYY-MM-DD' format.
Returned value:
Returns true if a value is a valid date, otherwise - false.
Type: Boolean
E8App.$date.isValid('2016-02-29');
Get month
Syntax:
E8App.$date.month(<value>)
Description:
Extracts the month from a given date.
Parameters:
<value> - required
Type: String
Date in 'YYYY-MM-DD' format.
Returned value:
The month part of a date.
Type: Number
E8App.$date.month('2005-06-27');
Get the start of month
Syntax:
E8App.$date.startOfMonth(<value>)
Description:
Returns the date containing the first day of month of a given date.
Parameters:
<value> - required
Type: String
Date in 'YYYY-MM-DD' format.
Returned value:
The date of the first day of the same month as the date value.
Type: String
E8App.$date.startOfMonth('1991-02-21');
Get the start of quarter
Syntax:
E8App.$date.startOfQuarter(<value>)
Description:
Returns the date containing the first day of quarter of a given date.
Parameters:
<value> - required
Type: String
Date in 'YYYY-MM-DD' format.
Returned value:
The date of the first day of quarter of a given date.
Type: String
E8App.$date.startOfQuarter('1980-01-25');
Get the start of week
Syntax:
E8App.$date.startOfWeek(<value>)
Description:
Returns the date containing the first day of week of a given date.
Parameters:
<value> - required
Type: String
Date in 'YYYY-MM-DD' format.
Returned value:
The date of the first day of week of a given date.
Type: String
E8App.$date.startOfWeek('2021-07-25');
Get the start of year
Syntax:
E8App.$date.startOfYear(<value>)
Description:
Returns the date containing the first day of year of a given date.
Parameters:
<value> - required
Type: String
Date in 'YYYY-MM-DD' format.
Returned value:
The date of the first day of the same year as the date value.
Type: String
E8App.$date.startOfYear('2011-03-11');
Get year
Syntax:
E8App.$date.year(<value>)
Description:
Extracts the year from a date.
Parameters:
<value> - required
Type: String
Date in 'YYYY-MM-DD' format.
Returned value:
The year part of a date.
Type: Number
E8App.$date.year('2011-05-22');