DateTime


A date, time, or date-and-time value. Note that all DateTime values include both a date and a time component. If you don't specify a date or a time, then that portion of the value is typically set to zero when the value is stored. Methods and properties include:

AddDays

AddHours

AddMilliseconds

AddMinutes

AddMonths

AddSeconds

AddTicks

AddYears

Adds the specified interval to the value. To subtract a value, specify a negative interval. Note that the type does include a Subtract() method; from within a PowerShell script one of these "Add" methods is generally easier to work with.

 PS C:\> [datetime]$d = "1/1/2000 3:00 PM" PS C:\> $d.adddays(1) Sunday, January 02, 2000 3:00:00 PM 

GetDateTimeFormats

Returns all possible string representations of the value.

 PS C:\> [datetime]$d = "1/1/2000 3:00 PM" PS C:\> $d.getdatetimeformats() 1/1/2000 1/1/00 01/01/00 01/01/2000 00/01/01 2000-01-01 01-Jan-00 Saturday, January 01, 2000 January 01, 2000 Saturday, 01 January, 2000 01 January, 2000 Saturday, January 01, 2000 3:00 PM Saturday, January 01, 2000 03:00 PM Saturday, January 01, 2000 15:00 Saturday, January 01, 2000 15:00 January 01, 2000 3:00 PM January 01, 2000 03:00 PM 

(output truncated in this example)

IsDaylightSavingTime

Indicates whether this instance of DateTime is within the Daylight Saving Time range for the current time zone.

 PS C:\> [datetime]$d = "1/1/2000 3:00 PM" PS C:\> $d.isdaylightsavingtime() False 

ToFileTime ToFileTimeUTC

Converts the value to a Windows file time. The "UTC" version provides a Universal Time Constant version of the value.

 PS C:\> [datetime]$d = "1/1/2000 3:00 PM" PS C:\> $d.tofiletimeutc() 125912124000000000 PS C:\> $d.tofiletime() 125912412000000000 

ToLocalTime

Converts the value to a local time.

 PS C:\> [datetime]$d = "1/1/2000 3:00 PM" PS C:\> $d.tolocaltime() Saturday, January 01, 2000 7:00:00 AM 

ToLongDateString

ToLongTimeString

ToShortDateString

ToShortTimeString

Converts the value to the appropriate date or time format.

 PS C:\> [datetime]$d = "1/1/2000 3:00 PM" PS C:\> $d.tolongdatestring() Saturday, January 01, 2000 PS C:\> $d.toshortdatestring() 1/1/2000 

ToUniversalTime

Converts the value to a Universal Time Constant (UTC), taking time zone changes into account.

 PS C:\> [datetime]$d = "1/1/2000 3:00 PM" PS C:\> $d.touniversaltime() Saturday, January 01, 2000 11:00:00 PM 

Day

DayOfWeek

DayOfYear

Hour

Millisecond

Minute

Month

Second

Ticks

TimeOfDay

Year

Returns only the specified portion of the value.

 PS C:\> [datetime]$d = "1/1/2000 3:00 PM" PS C:\> $d.day 1 PS C:\> $d.month 1 PS C:\> $d.dayofweek Saturday PS C:\> $d.timeofday Days              : 0 Hours             : 15 Minutes           : 0 Seconds           : 0 Milliseconds      : 0 Ticks             : 540000000000 TotalDays         : 0.625 TotalHours        : 15 TotalMinutes      : 900 TotalSeconds      : 54000 TotalMilliseconds : 54000000 



Windows PowerShell. TFM
Internet Forensics
ISBN: 982131445
EAN: 2147483647
Year: 2004
Pages: 289

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net