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> getMonthAbbrFromNumber(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
, andyears
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