In both the 3.0/2.0 SDK and 3.5/2.5 SDK, when I use the CurrentTime method against my ServiceInstance object, the timezone returned is always "Greenwich Mean Time" and the daylight savings flag is not set. The time reported, however, has been adjusted to be in my client's timezone (off by the number of minutes that are different between servers on top of the timezone difference). I need to know the timezone of the server and the actual unadjusted time. (as an aside, the serverClock property also shows GMT).
For example, the server shows a time of 11:38 AM CDT. My client is 9:35 AM PDT. CurrenTime returns 9:38 AM GMT. I want it to return 11:38 CDT!
A few things:
- CurrentDateTime should return a GMT value. I checked the MOB and this seems to be true. Perhaps your client was massaging the value before you actually saw it?
As you can see, the time is 12:xx and my time is actually 7AM, hence GMT - CDT (5 hours).
- CurrentDateTime does not seem to be the only method you can use to get time values. There is also the QueryDateTime method defined on the HostDateTimeSystem object, and you can get a list of time zones available to the host with QueryAvailableTimeZones.
Hope this helps!
The only method returning the current time on the server is CurrentTime, defined on ServiceInstance. Another property associated with fetching server time is serverClock, thouh it is best used for monitoring the change in time. Unfortunately, there is no method available specificifically for returning only the timezone of the server.
I have used the following and successfully fetched the current time of the esx server.
Util::connect();
my $service_instance = Vim::get_service_instance();
$service_instance->CurrentTime();
Thanks, but I am using CurrentTime(). My problem is that it does not return the correct time on the server. It is returning an adjusted time based on the client's timezone. Is your server and client in the same or different timezones?
Another observation is that the time structure from CurrentTime() indicates GMT, but the time returned is not GMT, it is the local time zone. Does your return from CurrentTime show GMT or does it show the correct server timezone?
A few things:
- CurrentDateTime should return a GMT value. I checked the MOB and this seems to be true. Perhaps your client was massaging the value before you actually saw it?
As you can see, the time is 12:xx and my time is actually 7AM, hence GMT - CDT (5 hours).
- CurrentDateTime does not seem to be the only method you can use to get time values. There is also the QueryDateTime method defined on the HostDateTimeSystem object, and you can get a list of time zones available to the host with QueryAvailableTimeZones.
Hope this helps!
Thanks. It looks like these query methods are new for VI SDK 2.5. I haven't upgraded yet, but will play around with it as soon as I do.
Hi!
just found the timezone definition for a ESX host here:
Data Object Type: HostDateTimeSystemTimeZone
Parent Managed Object ID: host-8561
Property Path: config.dateTimeInfo.timeZone
Tos2k
Well, it looks like most of this has been addressed in SDK 2.5. I guess I'll need to upgrade sooner than later.
Thanks!