Class: Date

Date

new Date()

Methods

<static> compare(date1, date2) → {Number}

Compares two dates

Parameters:
Name Type Description
date1 Date

first date

date2 Date

second date

Returns:

-1 if date1 is less than date2, 0 if they are equal, 1 if date1 is more than date2

Type
Number

<static> equals(date1, date2) → {Boolean}

Compares two dates to the millisecond

Parameters:
Name Type Description
date1 Date

first date

date2 Date

second date

Returns:
Type
Boolean

<static> equalsDay(date1, date2) → {Boolean}

Compares two dates by day

Parameters:
Name Type Description
date1 Date

first date

date2 Date

second date

Returns:
Type
Boolean

<static> getDayNumberFromName(day) → {Number}

Returns the day number for a day [0-6]

Parameters:
Name Type Description
day String

day name

Returns:
Type
Number

<static> getDaysInMonth(year, month) → {Number}

Returns the number of days in a month

Parameters:
Name Type Description
year Number

year

month Number

month

Returns:
Type
Number

<static> getMonthAbbrNameFromNumber(month) → {String}

Returns the month name abbreviated for a month [0-11]

Parameters:
Name Type Description
month Number

month

Returns:
Type
String

<static> getMonthNameFromNumber(month) → {String}

Returns the month name for a month [0-11]

Parameters:
Name Type Description
month Number

month

Returns:
Type
String

<static> getMonthNumberFromName(month) → {Number}

Returns the day number for a month [0-11]

Parameters:
Name Type Description
month String

month name

Returns:
Type
Number

<static> isLeapYear(year) → {Boolean}

Returns whether or not the year is a leap year

Parameters:
Name Type Description
year Number

year

Returns:
Type
Boolean

<static> today() → {Date}

Returns new instance of Date object with the date set to today and the time set to midnight

Returns:

Today's Date

Type
Date

<static> tomorrow() → {Date}

Returns new instance of Date object with the date set to tomorrow and the time set to midnight

Returns:

Tomorrow's Date

Type
Date

<static> UTCtoday() → {Date}

Returns new instance of Date object with the date set to today and the time set to midnight in UTC

Returns:

Today's Date in UTC

Type
Date

<static> UTCtomorrow() → {Date}

Returns new instance of Date object with the date set to tomorrow and the time set to midnight in UTC

Returns:

Tomorrow's Date in UTC

Type
Date

<static> UTCyesterday() → {Date}

Returns new instance of Date object with the date set to yesterday and the time set to midnight in UTC

Returns:

Yesterday's Date in UTC

Type
Date

<static> validateDay(day, year, month) → {Boolean}

Returns whether the day is valid

Parameters:
Name Type Description
day Number

day of the month

year Number

year

month Number

month of the year [0-11]

Returns:
Type
Boolean

<static> validateHour(hour) → {Boolean}

Returns whether the hour is valid [0-23]

Parameters:
Name Type Description
hour Number

hour

Returns:
Type
Boolean

<static> validateMillisecond(millisecond) → {Boolean}

Returns whether the millisecond is valid

Parameters:
Name Type Description
millisecond Number

millisecond

Returns:
Type
Boolean

<static> validateMinute(minute) → {Boolean}

Returns whether the minute is valid

Parameters:
Name Type Description
minute Number

minute

Returns:
Type
Boolean

<static> validateMonth(month) → {Boolean}

Returns whether the month is valid [0-11]

Parameters:
Name Type Description
month Number

month

Returns:
Type
Boolean

<static> validateSecond(second) → {Boolean}

Returns whether the second is valid

Parameters:
Name Type Description
second Number

second

Returns:
Type
Boolean

<static> validateYear(year) → {Boolean}

Returns whether the year is valid

Parameters:
Name Type Description
year Number

year

Returns:
Type
Boolean

<static> yesterday() → {Date}

Returns new instance of Date object with the date set to yesterday and the time set to midnight

Returns:

Yesterday's Date

Type
Date

add(additions) → {Date}

Adds milliseconds, seconds, minutes, hours, days, weeks, months, and years and returns a new Date. Usage: data.add({ "seconds": 10, "days": 1 })

Parameters:
Name Type Description
additions Object
Returns:
Type
Date

addHours(hours) → {Date}

Adds hours to the Date and returns it

Parameters:
Name Type Description
hours Number

Number of hours to add

Deprecated:
  • Will be deprecated in version 2.0 in favor of add
Returns:
Type
Date

addMilliseconds(milliseconds) → {Date}

Adds milliseconds to the Date and returns it

Parameters:
Name Type Description
milliseconds Number

Number of milliseconds to add

Deprecated:
  • Will be deprecated in version 2.0 in favor of add
Returns:
Type
Date

addMinutes(minutes) → {Date}

Adds minutes to the Date and returns it

Parameters:
Name Type Description
minutes Number

Number of minutes to add

Deprecated:
  • Will be deprecated in version 2.0 in favor of add
Returns:
Type
Date

addMonths(months) → {Date}

Adds months to the Date and returns it

Parameters:
Name Type Description
months Number

Number of months to add

Deprecated:
  • Will be deprecated in version 2.0 in favor of add
Returns:
Type
Date

addSeconds(seconds) → {Date}

Adds seconds to the Date and returns it

Parameters:
Name Type Description
seconds Number

Number of seconds to add

Deprecated:
  • Will be deprecated in version 2.0 in favor of add
Returns:
Type
Date

addSeconds(days) → {Date}

Adds days to the Date and returns it

Parameters:
Name Type Description
days Number

Number of days to add

Deprecated:
  • Will be deprecated in version 2.0 in favor of add
Returns:
Type
Date

addWeekdays(weekdays) → {Date}

Adds weekdays based on a Mon-Fri work schedule and returns it

Parameters:
Name Type Description
weekdays Number

Number of weekdays to add

Returns:
Type
Date

addWeeks(weeks) → {Date}

Adds weeks to the Date and returns it

Parameters:
Name Type Description
weeks Number

Number of weeks to add

Deprecated:
  • Will be deprecated in version 2.0 in favor of add
Returns:
Type
Date

addYears(years) → {Date}

Adds years to the Date and returns it

Parameters:
Name Type Description
years Number

Number of years to add

Deprecated:
  • Will be deprecated in version 2.0 in favor of add
Returns:
Type
Date

between() → {Boolean}

Returns whether this Date is between a start and end date

Returns:
Type
Boolean

clearTime() → {Date}

Sets the time to 00:00:00.0000 and returns a new Date object

Returns:
Type
Date

clearUTCTime() → {Date}

Sets the time to 00:00:00.0000 and returns a new Date object with set to UTC

Returns:
Type
Date

clone()

Returns a cloned copy of the current Date

compareTo(Date) → {Number}

Compares a Date to this Date

Parameters:
Name Type Description
Date Date

to compare to

Returns:

-1 if less than date, 0 if they are equal, 1 if more than date

Type
Number

equals(Date) → {Boolean}

Compares a Date and time to this Date and time for equality

Parameters:
Name Type Description
Date Date

to compare to

Returns:
Type
Boolean

equalsDay(Date) → {Boolean}

Compares a Date to this Date for equality

Parameters:
Name Type Description
Date Date

to compare to

Returns:
Type
Boolean

getDaysBetween(Date) → {Number}

Returns the number of days between this Date and the Date passed in

Parameters:
Name Type Description
Date Date

to compare to

Returns:
Type
Number

getFullWeekNumber() → {Number}

Returns the week number of this Date, zero padded

Returns:
Type
Number

getHoursBetween(Date) → {Number}

Returns the number of hours between this Date and the Date passed in

Parameters:
Name Type Description
Date Date

to compare to

Returns:
Type
Number

getLastMonthName() → {String}

Returns the name of last month

Returns:
Type
String

getMillisecondsBetween(Date) → {Number}

Returns the number of milliseconds between this Date and the Date passed in

Parameters:
Name Type Description
Date Date

to compare to

Returns:
Type
Number

getMinutesBetween(Date) → {Number}

Returns the number of minutes between this Date and the Date passed in

Parameters:
Name Type Description
Date Date

to compare to

Returns:
Type
Number

getMonthAbbr() → {String}

Returns the abbreviated month name

Returns:
Type
String

getMonthName() → {String}

Returns the month name

Returns:
Type
String

getMonthsBetween(Date) → {Number}

Returns the number of months between this Date and the Date passed in

Parameters:
Name Type Description
Date Date

to compare to

Returns:
Type
Number

getOrdinalNumber() → {Number}

Returns the ordinal number of this Date

Returns:
Type
Number

getSecondsBetween(Date) → {Number}

Returns the number of seconds between this Date and the Date passed in

Parameters:
Name Type Description
Date Date

to compare to

Returns:
Type
Number

getUTCOffset() → {String}

Returns the current UTC office

Returns:
Type
String

getWeekNumber() → {Number}

Returns the week number of this Date

Returns:
Type
Number

isAfter(Date) → {Boolean}

Compares a Date to this Date for to see if it is after the Date passed

Parameters:
Name Type Description
Date Date

to compare to

Returns:
Type
Boolean

isBefore(Date) → {Boolean}

Compares a Date to this Date for to see if it is before the Date passed

Parameters:
Name Type Description
Date Date

to compare to

Returns:
Type
Boolean

isToday() → {Boolean}

Checks to see if the Date is today

Returns:
Type
Boolean

isWeekend() → {Boolean}

Returns true if the Date is a weekend using standard Saturday/Sunday definition of a weekend

Returns:
Type
Boolean

remove(removals) → {Date}

Removes milliseconds, seconds, minutes, hours, days, weeks, months, and years and returns a new Date. Usage: data.remove({ "seconds": 10, "days": 1 })

Parameters:
Name Type Description
removals Object
Returns:
Type
Date

removeDays(days) → {Date}

Removes days from the Date and returns it

Parameters:
Name Type Description
days Number

Number of days to remove

Deprecated:
  • Will be deprecated in version 2.0 in favor of remove
Returns:
Type
Date

removeHours(hours) → {Date}

Removes hours from the Date and returns it

Parameters:
Name Type Description
hours Number

Number of hours to remove

Deprecated:
  • Will be deprecated in version 2.0 in favor of remove
Returns:
Type
Date

removeMilliseconds(milliseconds) → {Date}

Removes milliseconds from the Date and returns it

Parameters:
Name Type Description
milliseconds Number

Number of millseconds to remove

Deprecated:
  • Will be deprecated in version 2.0 in favor of remove
Returns:
Type
Date

removeMinutes(seconds) → {Date}

Removes minutes from the Date and returns it

Parameters:
Name Type Description
seconds Number

Number of minutes to remove

Deprecated:
  • Will be deprecated in version 2.0 in favor of remove
Returns:
Type
Date

removeMonths(months) → {Date}

Removes months from the Date and returns it

Parameters:
Name Type Description
months Number

Number of months to remove

Deprecated:
  • Will be deprecated in version 2.0 in favor of remove
Returns:
Type
Date

removeSeconds(seconds) → {Date}

Removes seconds from the Date and returns it

Parameters:
Name Type Description
seconds Number

Number of seconds to remove

Deprecated:
  • Will be deprecated in version 2.0 in favor of remove
Returns:
Type
Date

removeWeeks(weeks) → {Date}

Removes weeks from the Date and returns it

Parameters:
Name Type Description
weeks Number

Number of weeks to remove

Deprecated:
  • Will be deprecated in version 2.0 in favor of remove
Returns:
Type
Date

removeYears(years) → {Date}

Removes years from the Date and returns it

Parameters:
Name Type Description
years Number

Number of years to remove

Deprecated:
  • Will be deprecated in version 2.0 in favor of remove
Returns:
Type
Date

setTimeToNow()

Sets the time and date to now

toCLFString() → {String}

Returns a padded Common Log Format

Deprecated:
  • Will be deprecated in version 2.0 in favor of toFormat
Returns:
Type
String

toDBString() → {String}

Returns a formatted String for database insertion

Deprecated:
  • Will be deprecated in version 2.0 in favor of toFormat
Returns:
Type
String

toFormat(format) → {String}

Returns the a formatted version of this Date

Parameters:
Name Type Description
format String

Format of the Date, using YYYY, YY, MM, DD, HH, HH24, MI, SS, etc

Returns:
Type
String

toUTCFormat(format) → {String}

Returns the a formatted version of the UTC version of this Date

Parameters:
Name Type Description
format String

Format of the Date, using YYYY, YY, MM, DD, HH, HH24, MI, SS, etc

Returns:
Type
String

toYMD(separator) → {String}

Returns a padded Year/Month/Day

Parameters:
Name Type Description
separator String

optional, defaults to "-"

Deprecated:
  • Will be deprecated in version 2.0 in favor of toFormat
Returns:
Type
String