![]() The Seconds property is totally different from the TotalSeconds property. The TotalSeconds property, however, will return the value 130, which is the total duration of the TimeSpan in seconds.īe very careful when choosing the property to express the duration of a TimeSpan in a specific interval. If a TimeSpan value represents 2 minutes and 10 seconds, the Seconds property will return the value 10. The number of whole seconds in the current TimeSpan The number of whole minutes in the current TimeSpan The number of whole milliseconds in the current TimeSpan The number of hours in the current TimeSpan The number of days in the current TimeSpan Table 9.5: The Total Intervals of a TimeSpan Value Property The number of whole ticks in the current TimeSpan. The largest value of this property is 59. The number of whole seconds in the current TimeSpan. The number of whole minutes in the current TimeSpan. The largest value of this property is 999. The number of whole milliseconds in the current TimeSpan. The number of whole hours in the current TimeSpan. The number of whole days in the current TimeSpan. Table 9.4: The Intervals of a TimeSpan Value Property The second group of properties returns the entire TimeSpan’s duration in one of the intervals recognized by the TimeSpan method. ![]() The members of the first group of properties return the number of specific intervals (days, hours, and so on) in a TimeSpan value. In addition to the fields, the TimeSpan class exposes two more groups of properties that return the various intervals in a TimeSpan value (shown in Tables 13.4 and 13.5). The smallest interval you can represent with a TimeSpan object The largest interval you can represent with a TimeSpan object ![]() Table 9.3: The Fields of the TimeSpan Object Property TimeSpan exposes the simple properties shown in Table 13.3, which are known as fields and are all shared. The TimeSpan type exposes the properties described in the following sections. The difference represented by this value is 8,086 days, 15 hours, 37 minutes, 1 second, and 633,600 nanoseconds (or 633.6 milliseconds). Notice that a TimeSpan object might represent an interval of many years, but it doesn’t provide members to report months or years. The days are separated from the rest of the string with a period, whereas the time parts are separated with colons. You can initialize an instance of the TimeSpan object by creating two date/time values and getting their difference, as in the following statements: Dim TS As New TimeSpanĭebug.WriteLine(TS) Code language: PHP ( php )ĭepending on the day on which you execute these statements, they will print something like the following in the Output window: 8086. The following statement initializes a TimeSpan object to a duration of 9 days, 12 hours, 1 minute, and 59 seconds: Dim TS As TimeSpan = New TimeSpan( 9, 12, 1, 59) Code language: PHP ( php )Īs you have seen, the difference between two dates calculated by the Date.Subtract method returns a TimeSpan value. To initialize the TimeSpan object, you can provide the number of days, hours, minutes, seconds, and milliseconds that make up the time interval. To use the TimeSpan variable in your code, just declare it with a statement such as the following: Dim TS As New TimeSpan Code language: PHP ( php ) ![]() The TimeSpan is usually the difference between two date/time values, but you can also create a TimeSpan for a specific interval and use it in your calculations. The last class discussed in this chapter is the TimeSpan class, which represents a time interval and can be expressed in many different units - from ticks and milliseconds to days. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |