Initializes a new instance of the DateTime to the current date and time.
Initializes a new instance of the DateTime to a specified number of ticks.
A date and time expressed in the number of 100-nanosecond intervals that have elapsed since January 1, 0001 at 00:00:00.000 in the Gregorian calendar.
Initializes a new instance of the DateTime to the current date and time. Initializes a new instance of the DateTime to a specified number of ticks. Initializes a new instance of the DateTime to the specified year, month, and day. Initializes a new instance of the DateTime to the specified year, month, day, hour, minute, and second. Initializes a new instance of the DateTime to the specified year, month, day, hour, minute, second, and millisecond.
Initializes a new instance of the DateTime to the specified year, month, and day.
The year (1 through 9999).
The month (1 through 12).
The day (1 through the number of days in month).
Initializes a new instance of the DateTime to the specified year, month, day, hour, minute, and second.
The year (1 through 9999).
The month (1 through 12).
The day (1 through the number of days in month).
The hours (0 through 23).
The minutes (0 through 59).
The seconds (0 through 59).
Initializes a new instance of the DateTime to the specified year, month, day, hour, minute, second, and millisecond.
The year (1 through 9999).
The month (1 through 12).
The day (1 through the number of days in month).
The hours (0 through 23).
The minutes (0 through 59).
The seconds (0 through 59).
The milliseconds (0 through 999).
Initializes a new instance of the DateTime to the current date and time. Initializes a new instance of the DateTime to a specified number of ticks. Initializes a new instance of the DateTime to the specified year, month, and day. Initializes a new instance of the DateTime to the specified year, month, day, hour, minute, and second. Initializes a new instance of the DateTime to the specified year, month, day, hour, minute, second, and millisecond.
The year (1 through 9999).
The month (1 through 12).
The day (1 through the number of days in month).
The hours (0 through 23).
The minutes (0 through 59).
The seconds (0 through 59).
The milliseconds (0 through 999).
The day-of-month part of this DateTime. The value is between 1 and 31.
The day-of-week part of this DateTime. The returned value is an integer between 0 and 6, where 0 indicates Sunday, 1 indicates Monday, 2 indicates Tuesday, 3 indicates Wednesday, 4 indicates Thursday, 5 indicates Friday, and 6 indicates Saturday.
The day-of-year part of this DateTime. The value is between 1 and 366.
The hour part of this DateTime. The value is between 0 and 23.
The millisecond part of this DateTime. The value is between 0 and 999.
The minute part of this DateTime. The value is between 0 and 59.
The month part of this DateTime. The value is an integer between 1 and 12.
The second part of this DateTime. The value is between 0 and 59.
Returns the tick count for this DateTime. The returned value is the number of 100-nanosecond intervals that have elapsed since 1/1/0001 12:00am.
The year part of this DateTime. The value is between 1 and 9999.
Adds a fractional number of days to this DateTime. The result is computed by rounding the fractional number of days given by value to the nearest millisecond, and adding that interval to this DateTime. The value argument is permitted to be negative.
The number of days to add.
Add a fractional number of hours to this DateTime. The result is computed by rounding the fractional number of hours given by value to the nearest millisecond, and adding that interval to this DateTime. The value argument is permitted to be negative.
The number of hours to add.
Add a given number of milliseconds to this DateTime. The result is computed by rounding the number of milliseconds given by value to the nearest integer, and adding that interval to this DateTime. The value argument is permitted to be negative.
The number of milliseconds to add.
Add a fractional number of minutes to this DateTime. The result is computed by rounding the fractional number of minutes given by value to the nearest millisecond, and adding that interval to this DateTime. The value argument is permitted to be negative.
The number of fractional minutes to add.
Adds the given number of months to this DateTime. The result is computed by incrementing (or decrementing) the year and month parts of this DateTime by months, and, if required, adjusting the day part of the resulting date downwards to the last day of the resulting month in the resulting year. The time-of-day part of the result is the same as the time-of-day part of this DateTime.
In more precise terms, considering this DateTime to be of the form y / m / d + t, where y is the year, m is the month, d is the day, and t is the time-of-day, the result is y1 / m1 / d1 + t, where y1 and m1 are computed by adding months months to y and m, and d1 is the largest value less than or equal to d that denotes a valid day in month m1 of year y1.
The number of months to add.
Adds a fractional number of seconds to this DateTime. The result is computed by rounding the fractional number of seconds given by value to the nearest millisecond, and adding that interval to this DateTime. The value argument is permitted to be negative.
Add the given number of 100-nanosecond ticks to this DateTime. The value argument is permitted to be negative.
the number of ticks to add.
Add the given number of years to this DateTime. The result is computed by incrementing (or decrementing) the year part of this DateTime by value years. If the month and day of this DateTime is 2/29, and if the resulting year is not a leap year, the month and day of the resulting DateTime becomes 2/28. Otherwise, the month, day, and time-of-day parts of the result are the same as those of this DateTime.
The number of years to add.
Compares two DateTimes.
The DateTime to compare to the current instance.
A signed number indicating the relative values of this instance and the value parameter. | Value | Description | | -1 | This instance is earlier than value | | 0 | This instance is same as value | | 1 | This instance is greater than value |
Checks whether a DateTime or Date is equal to current instance.
The object to compare to this instance.
true if the value parameter equals the value of this instance; otherwise, false.
DateTime as Javascript Date
A Javascript Date object that represent this DateTime instance.
Turns DateTime into a string with the specified format.
Patterns | Format | Description | Example |
---|---|---|---|
h | 0 | 12 hour w/o leading zero | 3 |
hh | 00 | 12 hour with leading zero | 03 |
hh* | 00 | 12 hour with leading zero | 03 |
H | 0 | 24 hour w/o leading zero | 8 |
HH | 00 | 24 hour with leading zero | 08 |
HH* | 00 | 24 hour with leading zero | 08 |
m | 0 | minute w/o leading zero | 1 |
mm | 00 | minute with leading zero | 01 |
mm* | 00 | minute with leading zero | 01 |
s | 0 | second w/o leading zero | 5 |
ss | 00 | second with leading zero | 05 |
ss* | 00 | second with leading zero | 05 |
t | - | first character of AM/PM designator | A/P |
tt | - | AM/PM designator | AM/PM |
tt* | - | AM/PM designator | AM/PM |
d | 0 | day w/o leading zero | 1 |
dd | 00 | day with leading zero | 01 |
ddd | - | short weekday name (abbreviation) | Mon |
dddd | - | full weekday name | Monday |
dddd* | - | full weekday name | Monday |
M | 0 | month w/o leading zero | 2 |
MM | 00 | month with leading zero | 02 |
MMM | - | short month name (abbreviation) | Feb |
MMMM | - | full month name | February |
MMMM* | - | full month name | February |
y | 0 | two digit year (year % 100) w/o leading zero | 1 |
yy | 00 | two digit year (year % 100) with leading zero | 01 |
yyyy | 0000 | full year | 2019 |
yyyy* | 0000 | full year | 2019 |
'...' | - | quoted string, ignore matching values | 'ABC' |
The format you would like the string in
The number of days in the month
The year of the month
The month we want to know the days of.
Whether a given year is a leap year
A year to check
Generated using TypeDoc
Represents an instant in time, typically expressed as a date and time of day.