DateAndTime DateAndTime DateAndTime DateAndTime Class

定义

DateAndTime 模块包含在日期和时间操作中使用的过程和属性。The DateAndTime module contains the procedures and properties used in date and time operations.

public ref class DateAndTime sealed
[Microsoft.VisualBasic.CompilerServices.StandardModule]
public sealed class DateAndTime
type DateAndTime = class
Public Module DateAndTime
继承
DateAndTimeDateAndTimeDateAndTimeDateAndTime
属性

示例

此示例使用Today属性返回当前系统日期。This example uses the Today property to return the current system date.

Dim thisDate As Date  
thisDate = Today   

注解

此模块支持 Visual Basic 语言关键字和运行库成员,它们可获取当前日期或时间、执行日期计算、返回日期或时间、设置日期或时间,或设置进程的持续时间。This module supports the Visual Basic language keywords and run-time library members that get the current date or time, perform date calculations, return a date or time, set the date or time, or time the duration of a process.

属性

DateString DateString DateString DateString

返回或设置一个字符串值,该值表示与系统对应的当前日期。Returns or sets a string value representing the current date according to your system.

Now Now Now Now

返回一个值,该值包含与系统对应的当前日期和时间。Returns a value containing the current date and time according to your system.

TimeOfDay TimeOfDay TimeOfDay TimeOfDay

返回或设置 Date 值,该值包含与系统对应的当前时间。Returns or sets a Date value containing the current time of day according to your system.

Timer Timer Timer Timer

返回一个 Double 值,该值表示午夜之后的秒数。Returns a Double value representing the number of seconds elapsed since midnight.

TimeString TimeString TimeString TimeString

根据系统返回或设置表示当前时间的字符串值。Returns or sets a string value representing the current time of day according to your system.

Today Today Today Today

返回或设置一个 Date 值,该值包含对应于系统的当前日期。Returns or sets a Date value containing the current date according to your system.

方法

DateAdd(DateInterval, Double, DateTime) DateAdd(DateInterval, Double, DateTime) DateAdd(DateInterval, Double, DateTime) DateAdd(DateInterval, Double, DateTime)

返回一个值,其中包含已添加指定时间间隔的日期和时间值。Returns a value containing a date and time value to which a specified time interval has been added.

DateAdd(String, Double, Object) DateAdd(String, Double, Object) DateAdd(String, Double, Object) DateAdd(String, Double, Object)

返回一个值,其中包含已添加指定时间间隔的日期和时间值。Returns a value containing a date and time value to which a specified time interval has been added.

DateDiff(DateInterval, DateTime, DateTime, FirstDayOfWeek, FirstWeekOfYear) DateDiff(DateInterval, DateTime, DateTime, FirstDayOfWeek, FirstWeekOfYear) DateDiff(DateInterval, DateTime, DateTime, FirstDayOfWeek, FirstWeekOfYear) DateDiff(DateInterval, DateTime, DateTime, FirstDayOfWeek, FirstWeekOfYear)

返回一个长值,该长值指定两个 Date 值之间的时间间隔数。Returns a long value specifying the number of time intervals between two Date values.

DateDiff(String, Object, Object, FirstDayOfWeek, FirstWeekOfYear) DateDiff(String, Object, Object, FirstDayOfWeek, FirstWeekOfYear) DateDiff(String, Object, Object, FirstDayOfWeek, FirstWeekOfYear) DateDiff(String, Object, Object, FirstDayOfWeek, FirstWeekOfYear)

返回一个长值,该长值指定两个 Date 值之间的时间间隔数。Returns a long value specifying the number of time intervals between two Date values.

DatePart(DateInterval, DateTime, FirstDayOfWeek, FirstWeekOfYear) DatePart(DateInterval, DateTime, FirstDayOfWeek, FirstWeekOfYear) DatePart(DateInterval, DateTime, FirstDayOfWeek, FirstWeekOfYear) DatePart(DateInterval, DateTime, FirstDayOfWeek, FirstWeekOfYear)

返回包含给定 Date 值的指定组件的整数值。Returns an integer value containing the specified component of a given Date value.

DatePart(String, Object, FirstDayOfWeek, FirstWeekOfYear) DatePart(String, Object, FirstDayOfWeek, FirstWeekOfYear) DatePart(String, Object, FirstDayOfWeek, FirstWeekOfYear) DatePart(String, Object, FirstDayOfWeek, FirstWeekOfYear)

返回一个值,其中包含给定 Date 值的指定组件。Returns an value containing the specified component of a given Date value.

DateSerial(Int32, Int32, Int32) DateSerial(Int32, Int32, Int32) DateSerial(Int32, Int32, Int32) DateSerial(Int32, Int32, Int32)

返回表示已指定年月日的 Date 值,其时间信息被设置为午夜 (00:00:00)。Returns a Date value representing a specified year, month, and day, with the time information set to midnight (00:00:00).

DateValue(String) DateValue(String) DateValue(String) DateValue(String)

返回一个 Date 值,该值包含用字符串表示的日期信息,其时间信息设置为午夜 (00:00:00)。Returns a Date value containing the date information represented by a string, with the time information set to midnight (00:00:00).

Day(DateTime) Day(DateTime) Day(DateTime) Day(DateTime)

返回表示月中第几天的整数值,该值介于 1 和 31 之间。Returns an integer value from 1 through 31 representing the day of the month.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
Hour(DateTime) Hour(DateTime) Hour(DateTime) Hour(DateTime)

返回表示天中第几个小时的整数值,该值介于 0 和 23 之间。Returns an integer value from 0 through 23 representing the hour of the day.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
Minute(DateTime) Minute(DateTime) Minute(DateTime) Minute(DateTime)

返回表示一小时内第几分钟的整数值,该值介于 0 和 59 之间。Returns an integer value from 0 through 59 representing the minute of the hour.

Month(DateTime) Month(DateTime) Month(DateTime) Month(DateTime)

返回表示一年中第几个月的整数值,该值介于 1 和 12 之间。Returns an integer value from 1 through 12 representing the month of the year.

MonthName(Int32, Boolean) MonthName(Int32, Boolean) MonthName(Int32, Boolean) MonthName(Int32, Boolean)

返回包含指定月份名称的字符串值。Returns a string value containing the name of the specified month.

Second(DateTime) Second(DateTime) Second(DateTime) Second(DateTime)

返回表示一分钟内第几秒的整数值,该值介于 0 和 59 之间。Returns an integer value from 0 through 59 representing the second of the minute.

TimeSerial(Int32, Int32, Int32) TimeSerial(Int32, Int32, Int32) TimeSerial(Int32, Int32, Int32) TimeSerial(Int32, Int32, Int32)

返回一个 Date 值,该值表示指定的小时、分钟和秒,其日期信息设置基点为元年 1 月 1 日。Returns a Date value representing a specified hour, minute, and second, with the date information set relative to January 1 of the year 1.

TimeValue(String) TimeValue(String) TimeValue(String) TimeValue(String)

返回一个 Date 值,该值包含以字符串表示的时间信息,其日期信息设置为元年 1 月 1 日。Returns a Date value containing the time information represented by a string, with the date information set to January 1 of the year 1.

ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)
Weekday(DateTime, FirstDayOfWeek) Weekday(DateTime, FirstDayOfWeek) Weekday(DateTime, FirstDayOfWeek) Weekday(DateTime, FirstDayOfWeek)

返回包含表示星期几的数字的整数值。Returns an integer value containing a number representing the day of the week.

WeekdayName(Int32, Boolean, FirstDayOfWeek) WeekdayName(Int32, Boolean, FirstDayOfWeek) WeekdayName(Int32, Boolean, FirstDayOfWeek) WeekdayName(Int32, Boolean, FirstDayOfWeek)

返回包含指定工作日的名称的整数值。Returns a string value containing the name of the specified weekday.

Year(DateTime) Year(DateTime) Year(DateTime) Year(DateTime)

返回表示年的 1 到 9999 之间的整数值。Returns an integer value from 1 through 9999 representing the year.

适用于

另请参阅