You can retrieve the ServiceInstance object to access the ServiceContent or to retrieve the current time on an ESXi or vCenter Server system.

If you want to retrieve the current time, you must retrieve a ServiceInstance object and call its CurrentTime() method. You can use the Vim::get_service_instance() subroutine to retrieve the object.

Procedure

  1. Connect to the VMware host.
    Util::connect();
  2. Retrieve the ServiceInstance object.
    my $service_instance = Vim::get_service_instance();
  3. Retrieve the current host time.
    $service_instance->CurrentTime();