System.Time.getLocalTime Method

Gets the system time for a specific time zone.

Syntax

strLocalTime = System.Time.getLocalTime(
  oTimeZone
)

Parameters

  • oTimeZone [in]
    object Sets System.Time.timeZone that specifies the desired time zone offset.
  • strLocalTime
    BSTR The system time, adjusted for time zone offset, as a String.

Return Value

HRESULT

If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

Each System.Time.timeZone in the timeZones collection corresponds to the system time zones itemized in the Time Zone Settings dialog.

The following image shows the Time Zone Settings dialog.

 

Time Zone Settings dialog

 

Examples

The following example demonstrates how to get the local time based on a selected time zone.

var oSelectedTimeZone = System.Time.currentTimeZone;
    
// --------------------------------------------------------------------
// Display the system time based on selected time zone.
// --------------------------------------------------------------------
function DisplayTime()
{
    // Retrieve the local time.
    var sTimeInfo = System.Time.getLocalTime(oSelectedTimeZone);
    if (sTimeInfo != "")
    {
        System.Sound.beep();
        var dDateInfo = new Date(Date.parse(sTimeInfo));   
        tHours = dDateInfo.getHours();
        tMinutes = dDateInfo.getMinutes();
        tMinutes = ((tMinutes < 10) ? ":0" : ":") + tMinutes
        tSeconds = dDateInfo.getSeconds();
        tSeconds = ((tSeconds < 10) ? ":0" : ":") + tSeconds;
        return tHours + tMinutes + tSeconds;
    }
    else
    {
        // Display default text.
    }
}

Requirements

Minimum supported client Windows Vista
Minimum supported server Windows Server 2008
DLL Sidebar.Exe version 1.00 or later

See Also

Reference

System.Time

currentTimeZone

timeZones

System.Time.timeZone

bias

displayName

DSTBias

DSTDate

DSTDisplayName

name

standardBias

standardDate

standardDisplayName

 

 

Send comments about this topic to Microsoft

Build date: 2/24/2010

Build type: SDK