Querying and Changing the Host Time

The HostDateTimeSystem supports date and time related configuration on a host and supports NTP configuration.

The HostDateTimeSystem.dateTimeInfo property allows you to retrieve and set date and time information. The HostDateTimeInfo data object’s properties contain two data object for date time management:

  • HostNTPConfig contains a list of NTP servers for use by the host.
  • HostDateTimeSystemTimeZone specifies the time zone including the GMT offset, identifier for the time zone, and name.

You can also query the host’s time information by calling one of the HostDateTimeSystem methods.

  • QueryAvailableTimeZones – Retrieves the list of available timezones on the host. The method uses the public domain tz timezone database. The method returns an array of HostDateTimeSystemTimeZone objects.
  • QueryDateTime – Returns the current date and time on the host.

You can modify the host’s date time information by calling one of the following HostDateTimeSystem methods:

  • RefreshDateTimeSystem – Refreshes the date and time related settings to pick up any changes that might have occurred.
  • UpdateDateTime – Updates the date and time on the host using the date and time passed into the method. Use with caution. Network delays or execution delays can result in time skews.
  • UpdateDateTimeConfig – Updates the date and time configuration of the host. You call this method with a HostDateTimeConfig parameter, which allows you to specify both the NTP configuration and the time zone.