Поделиться через


Win32_LocalTime class

The Win32_LocalTime WMI class describes a point in time returned as Win32_LocalTime objects that result from a query. These are returned as the value for the TargetInstance property in the __InstanceModificationEvent system class. The Hour property is returned as the local time on a 24-hour clock.

Note

The smallest time segment supported is 1 second.

The following syntax is simplified from Managed Object Format (MOF) code and includes all of the inherited properties. Properties are listed in alphabetic order, not MOF order.

Syntax

[dynamic, provider("Win32ClockProvider"), AMENDMENT]
class Win32_LocalTime : Win32_CurrentTime
{
  uint32 Day;
  uint32 DayOfWeek;
  uint32 Hour;
  uint32 Milliseconds;
  uint32 Minute;
  uint32 Month;
  uint32 Quarter;
  uint32 Second;
  uint32 WeekInMonth;
  uint32 Year;
};

Members

The Win32_LocalTime class has these types of members:

Properties

The Win32_LocalTime class has these properties.

Day

Data type: uint32

Access type: Read-only

Current day that matches the query (1 31).

This property is inherited from Win32_CurrentTime.

DayOfWeek

Data type: uint32

Access type: Read-only

Current day of the current week that matches the query (0 6). By convention, the value 0 is always Sunday, regardless of the culture or the locale set on the machine.

This property is inherited from Win32_CurrentTime.

Hour

Data type: uint32

Access type: Read-only

Current hour of the current day (0 23).

This property is inherited from Win32_CurrentTime.

Milliseconds

Data type: uint32

Access type: Read-only

Not implemented.

This property is inherited from Win32_CurrentTime.

Minute

Data type: uint32

Access type: Read-only

Current minute (0 59).

This property is inherited from Win32_CurrentTime.

Month

Data type: uint32

Access type: Read-only

Current month that matches the query (1 12).

This property is inherited from Win32_CurrentTime.

Quarter

Data type: uint32

Access type: Read-only

Current quarter of the current year (1 4).

This property is inherited from Win32_CurrentTime.

Second

Data type: uint32

Access type: Read-only

Current second of the current minute (0 59).

This property is inherited from Win32_CurrentTime.

WeekInMonth

Data type: uint32

Access type: Read-only

Current week (1 6) in the current month (1 12).

This property is inherited from Win32_CurrentTime.

Year

Data type: uint32

Access type: Read-only

Current year that matches the query (4 digits).

This property is inherited from Win32_CurrentTime.

Remarks

When you subscribe to events by using this class, you can create sophisticated schedules that can be implemented through events returned from WMI. For example, you can subscribe to an event for a specific day of a week in a specific quarter of a specific year.

For a discussion of determining the local time on a computer, see How Can I Determine the System Time on a Computer?

Examples

The following PowerShell example retrieves the local time for a computer.

Get-WmiObject -Class Win32_LocalTime -ComputerName . | Select-Object -Property [a-z]*

The following query example generates an event every Friday morning at 8:00:00 (local time) during the year 2001. If the line "AND TargetInstance.Second=0" is removed, then the query generates 60 notifications between 8:00:00 and 8:01:00, every Friday morning in 2001.

SELECT * FROM __InstanceModificationEvent
WHERE
    TargetInstance ISA "Win32_LocalTime" 
    AND TargetInstance.Year = 2001 
    AND TargetInstance.DayOfWeek=6 
    AND TargetInstance.Hour=8 
    AND TargetInstance.Minute=0 
    AND TargetInstance.Second=0

The following query example shows you how to generate events every second forever.

SELECT * FROM __InstanceModificationEvent
WHERE
    TargetInstance ISA "Win32_LocalTime"

Requirements

Minimum supported client
Windows Vista
Minimum supported server
Windows Server 2008
Namespace
Root\CIMV2
MOF
Wmitimep.mof
DLL
Wmitimep.dll

See also

Operating System Classes

Win32_UTCTime

Win32_CurrentTime

Creating a Timer Event with Win32_LocalTime or Win32_UTCTime

WMI Tasks: Dates and Times