System.DateTime

Summary


Represents an instant in time, typically expressed as a date and time of day.
Defined in DateTime.js

Constructors

System.DateTime(<Int> year, <Int> month, <Int> day, <Int> hour, <Int> minute, <Int> second, <Int> millisecond)
Initializes a new instance of the DateTime structure to the specified year, month, day, hour, minute, second, and millisecond.

Parameters

  • year - The year (1 through 9999).
  • month - The month (1 through 12).
  • day - The day (1 through the number of days in month).
  • hour - The hours (0 through 23).
  • minute - The minutes (0 through 59).
  • second - The seconds (0 through 59).
  • millisecond - The milliseconds (0 through 999).

Properties

  • static final DateTime MaxValue
    Represents the largest possible value of DateTime. This field is read-only. The value of this constant is equivalent to 23:59:59.9999999, December 31, 9999, exactly one 100-nanosecond tick before 00:00:00, January 1, 10000.
  • static final DateTime MinValue
    Represents the smallest possible value of DateTime. This field is read-only. The value of this constant is equivalent to 00:00:00.0000000, January 1, 1970 (the UNIX epoch).

Methods

  • DateTime AddDays(<Int> value)
    Adds the specified number of days to the value of this instance. This method does not change the value of this DateTime. Instead, a new DateTime is returned whose value is the result of this operation.

    Parameters

    • value - A number of whole days. The value parameter can be negative or positive.

    Return Values

    A DateTime whose value is the sum of the date and time represented by this instance and the number of days represented by value.
  • DateTime AddHours(<Int> value)
    Adds the specified number of hours to the value of this instance. This method does not change the value of this DateTime. Instead, a new DateTime is returned whose value is the result of this operation.

    Parameters

    • value - A number of whole hours. The value parameter can be negative or positive.

    Return Values

    A DateTime whose value is the sum of the date and time represented by this instance and the number of hours represented by value.
  • DateTime AddMilliseconds(<Int> value)
    Adds the specified number of milliseconds to the value of this instance. This method does not change the value of this DateTime. Instead, a new DateTime is returned whose value is the result of this operation.

    Parameters

    • value - A number of whole milliseconds. The value parameter can be negative or positive.

    Return Values

    A DateTime whose value is the sum of the date and time represented by this instance and the number of milliseconds represented by value.
  • DateTime AddMinutes(<Int> value)
    Adds the specified number of minutes to the value of this instance. This method does not change the value of this DateTime. Instead, a new DateTime is returned whose value is the result of this operation.

    Parameters

    • value - A number of whole minutes. The value parameter can be negative or positive.

    Return Values

    A DateTime whose value is the sum of the date and time represented by this instance and the number of minutes represented by value.
  • DateTime AddMonths(<Int> value)
    Adds the specified number of months to the value of this instance. This method does not change the value of this DateTime. Instead, a new DateTime is returned whose value is the result of this operation.

    Parameters

    • value - A number of whole months. The value parameter can be negative or positive.

    Return Values

    A DateTime whose value is the sum of the date and time represented by this instance and the number of months represented by value.
  • DateTime AddSeconds(<Int> value)
    Adds the specified number of seconds to the value of this instance. This method does not change the value of this DateTime. Instead, a new DateTime is returned whose value is the result of this operation.

    Parameters

    • value - A number of whole seconds. The value parameter can be negative or positive.

    Return Values

    A DateTime whose value is the sum of the date and time represented by this instance and the number of seconds represented by value.
  • DateTime AddYears(<Int> value)
    Adds the specified number of years to the value of this instance. This method does not change the value of this DateTime. Instead, a new DateTime is returned whose value is the result of this operation.

    Parameters

    • value - A number of years. The value parameter can be negative or positive.

    Return Values

    A DateTime whose value is the sum of the date and time represented by this instance and the number of years represented by value.
  • DateTime GetDate()
    Gets the date component of this instance.

    Return Values

    A new DateTime with the same date as this instance, and the time value set to 12:00:00 midnight (00:00:00).
  • Int GetDay()
    Gets the day of the month represented by this instance.

    Return Values

    The day component, expressed as a value between 1 and 31.
  • Int GetDayOfWeek()
    Gets the day of the week represented by this instance.

    Return Values

    An integer that indicates the day of the week. This property value ranges from zero, indicating Sunday, to six, indicating Saturday.
  • Int GetHour()
    Gets the hour component of the date represented by this instance.

    Return Values

    The hour component, expressed as a value between 0 and 23.
  • Int GetMillisecond()
    Gets the milliseconds component of the date represented by this instance.

    Return Values

    The milliseconds component, expressed as a value between 0 and 999.
  • Int GetMinute()
    Gets the minute component of the date represented by this instance.

    Return Values

    The minute component, expressed as a value between 0 and 59.
  • Int GetMonth()
    Gets the month component of the date represented by this instance.

    Return Values

    The month component, expressed as a value between 1 and 12.
  • Int GetSecond()
    Gets the seconds component of the date represented by this instance.

    Return Values

    The seconds, between 0 and 59.
  • Int GetYear()
    Gets the year component of the date represented by this instance.

    Return Values

    The year, between 1 and 9999.
  • String ToLongDateString()
    Converts the value of the current DateTime object to its equivalent long date string representation.

    Return Values

    A string that contains the long date string representation of the current DateTime object.
  • String ToLongTimeString()
    Converts the value of the current DateTime object to its equivalent long time string representation.

    Return Values

    A string that contains the long time string representation of the current DateTime object.
  • String ToShortDateString()
    Converts the value of the current DateTime object to its equivalent short date string representation.

    Return Values

    A string that contains the short date string representation of the current DateTime object.
  • String ToShortTimeString()
    Converts the value of the current DateTime object to its equivalent short time string representation.

    Return Values

    A string that contains the short time string representation of the current DateTime object.
  • String ToString(<String> format)
    Converts the value of the current DateTime object to its equivalent string representation using the specified format.
    • (d) Short date: 4/17/2006
    • (D) Long date: Monday, April 17, 2006
    • (t) Short time: 2:22 PM
    • (T) Long time: 2:22:48 PM
    • (f) Full date/short time: Monday, April 17, 2006 2:22 PM
    • (F) Full date/long time: Monday, April 17, 2006 2:22:48 PM
    • (g) General date/short time: 4/17/2006 2:22 PM
    • (G) General date/long time (default): 4/17/2006 2:22:48 PM
    • (M) Month: April 17
    • (s) Sortable: 2006-04-17T14:22:48
    • (Y) Year: April, 2006

    Parameters

    • format - A DateTime format string.

    Return Values

    A string representation of value of the current DateTime object as specified by format.
  • static Int DaysInMonth(<Int> year, <Int> month)
    Returns the number of days in the specified month and year.

    Parameters

    • year - The year.
    • month - The month (a number ranging from 1 to 12).

    Return Values

    The number of days in month for the specified year. If month equals 2 for February, the return value is 28 or 29 depending upon whether year is a leap year.
  • static Bool IsLeapYear(<Int> year)
    Returns an indication whether the specified year is a leap year.

    Parameters

    • year - A 4-digit year.

    Return Values

    True if year is a leap year; otherwise, false.
  • static DateTime Now()
    Gets a DateTime object that is set to the current date and time on this computer, expressed as the local time.

    Return Values

    A DateTime whose value is the current local date and time.
  • static DateTime Today()
    Gets the current date.

    Return Values

    A DateTime set to today's date, with the time component set to 00:00:00.