DateTime¶
Reference¶
- class DateTime¶
- module:
- toString()¶
Returns the datetime as a string
- Returns:
The datetime in YYYY-MM-DD HH:MM:SS format
- Return type:
str
- isLeapYear()¶
Checks if the year is a leap year
- Returns:
True if leap year, false otherwise
- Return type:
boolean
- getDaysInMonth()¶
Gets the number of days in the month
- Returns:
Number of days in the month
- Return type:
number
- addSeconds(seconds)¶
Adds seconds to the current datetime
- Parameters:
seconds (
number
) – Number of seconds to add
- addMinutes(minutes)¶
Adds minutes to the current datetime
- Parameters:
minutes (
number
) – Number of minutes to add
- addHours(hours)¶
Adds hours to the current datetime
- Parameters:
hours (
number
) – Number of hours to add
- addDays(days)¶
Adds days to the current datetime
- Parameters:
days (
number
) – Number of days to add
- addMonths(months)¶
Adds months to the current datetime (handles overflow)
- Parameters:
months (
number
) – Number of months to add
- addYears(years)¶
Adds years to the current datetime
- Parameters:
years (
number
) – Number of years to add
- compare(other)¶
Compares two DateTime objects
- Parameters:
other (
DateTime
) – The other datetime to compare- Returns:
-1 if this datetime is earlier, 0 if equal, 1 if later
- Return type:
number
- equals(other)¶
Checks if two datetimes are equal
- Parameters:
other (
DateTime
) – The other datetime to compare- Returns:
True if equal, false otherwise
- Return type:
boolean
- static now()¶
Creates a DateTime object representing the current date and time
- Returns:
The current date and time
- Return type:
- toTimestamp()¶
Converts the DateTime object to a Unix timestamp
- Returns:
The Unix timestamp
- Return type:
number