---
title: "Time"
canonical: "https://docs.cuesystem.com/space/CVCHELP/512327880/Time"
format: markdown
---
> Macro (toc)

---

# ConvertLocalTimeToUTCTime

This function converts local time in the current local time zone to UTC time. 

**The function is available since firmware 20.10**

#### Syntax 

```visualbasic
Function ConvertLocalTimeToUTCTime(localtime As Time, ByRef dstutctime As Time) As Boolean
```

#### Parameters 

localtime 

[<u>Time</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Time)<u> </u> It is source local time in the current local time zone

dstutctime

[<u>Time</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Time) It is UTC converted from local time. 

#### Return value 

[<u>Boolean</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean). The function returns True if the conversion was successful and False if an error occurs. If local time  is not valid then conversion is not possible and the function returns False. 

# ConvertUTCTimeToLocalTime

This function converts UTC to local time in the current local time zone. 

**The function is available since firmware 20.00**

#### Syntax 

```visualbasic
Function ConvertUTCTimeToLocalTime (utc As Time, ByRef dstlocaltime As Time) As Boolean
```

#### Parameters 

utc  

[<u>Time</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Time) It is source time in UTC. 

dstlocaltime 

[<u>Time</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Time)<u> </u> It is local time in the current local time zone converted from UTC. 

#### Return value 

[<u>Boolean</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean). The function returns True if the conversion was successful and False if an error occurs. If entered UTC is not valid then conversion is not possible and the function returns False. 

# GetCurrentTimeZoneInfo

This function returns information about the current time zone in the unit.** ** 

#### Syntax 

```visualbasic
Function GetCurrentTimeZoneInfo (ByRef timezoneinfo As _TimeZoneInfo) As Boolean
```

#### Parameters 

timezoneinfo 

[_TimeZoneInfo](/wiki/spaces/CVCHELP/pages/512327880/Time#_TimeZoneInfo). Destination of the current time zone info 

#### Return value 

[<u>Boolean</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)

***True*** – information about current time zone is set to variable timezoneinfo. 

***False*** – cannot get timezone info. 

# GetInternetClockEnabled

This function returns true if synchronization with the internet clock is enabled. 

#### Syntax 

```visualbasic
Function GetInternetClockIsEnabled () As Boolean
```

#### Return value 

[<u>Boolean</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean). The function returns true if synchronization with the internet clock is enabled. 

# GetLocalTime

This function returns the current time in a local time zone. 

#### Syntax 

```visualbasic
Function GetLocalTime() As Time
```

#### Return value 

[<u>Time</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Time) It is the current time. 

# GetLocalTimeStructure

This function places the structure datetime current time in the local time zone. 

#### Syntax 

```visualbasic
Function GetLocalTimeStructure(ByRef datetime As _TimeStructure) As Boolean
```

#### Parameters 

datetime 

[<u>_TimeStructure</u>](/wiki/spaces/CVCHELP/pages/512327880/Time#_TimeStructure) It is the current time. 

#### Return value 

[<u>Boolean</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean) It is True on success or False if an error occurs. The function GetLastError returns the error number. 

# GetLocalToUTCTimeOffset

This function returns an offset between the current local time and UTC. 

#### Syntax 

```visualbasic
Function GetLocalToUTCTimeOffset() As Time
```

#### Return value 

[<u>Time</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Time) It is offset between current local time and UTC.  

# GetLocalToUTCTimeOffsetExt

This function returns offset between specified local time in the current time zone and UTC. 

#### Syntax 

```visualbasic
Function GetLocalToUTCTimeOffsetExt(locatimeincurrenttimezone As Time) As Time
```

#### Return value 

[<u>Time</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Time) It is offset between specified local time in the current time zone and UTC. 

# GetNTPServers

This function returns names of NTP servers used by the CUEunit.** ** 

#### Syntax 

```visualbasic
Function GetNTPServers(ByRef ntpserver1 As Text, ByRef ntpserver2 As Text) As Boolean
```

#### Parameters

ntpserver1 

[<u>Text</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text) - the destination of the ntpserver1 name. 

ntpserver2 

[<u>Text</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text) - the destination of the ntpserver2 name. 

#### Return value 

[<u>Boolean</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean) 

***True*** All done. 

***False*** Parameters ntp1 or ntp2 are too short. 

# GetSystemTime

This function returns system time. The system time does not depend on a time zone. 

#### Syntax 

```visualbasic
Function GetSystemTime() As Time
```

#### Return value 

[<u>Time</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Time) It is system time. 

# GetTimeZoneInfo

This function returns information about a specified time zone.** ** 

#### Syntax 

```visualbasic
Function GetTimeZoneInfo (timezoneindex As Long, ByRef timezoneinfo As _TimeZoneInfo) As Boolean
```

#### Parameters 

timezoneindex 

[<u>Long</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long) - the index of the time zone. 

timezoneinfo 

[_TimeZoneInfo](/wiki/spaces/CVCHELP/pages/512327880/Time#_TimeZoneInfo). Destination of the time zone info 

#### Return value 

[<u>Boolean</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean) 

***True*** – information about time zone is set to variable timezoneinfo. 

***False*** – parameter timezoneindex is out of range. 

# GetTimeZonesCount

This function returns the time zones count.** ** 

#### Syntax 

```visualbasic
Function GetTimeZonesCount() As Long
```

#### Return value 

[<u>Long</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long) - Number of time zones in controller or panel. 

# GetUTCTime

This function returns the current UTC (Coordinated Universal Time) time. 

#### Syntax 

```visualbasic
Function GetUTCTime() As Time
```

#### Return value 

[<u>Time</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Time) It is the current time. 

# GetUTCTimeStructure

This function places to the structure datetime current UTC (Coordinated Universal Time) time. 

#### Syntax 

```visualbasic
Function GetUTCTimeStructure(ByRef datetime As _TimeStructure) As Boolean
```

#### Parameters 

datetime 

[<u>_TimeStructure</u>](/wiki/spaces/CVCHELP/pages/512327880/Time#_TimeStructure) It is the current time. 

#### Return value 

[<u>Boolean</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean) It is True on success or False if an error occurs. The function GetLastError returns the error number. 

# SetInternetClockEnabled

This function returns true if synchronization with the internet clock is enabled. 

#### Syntax 

```visualbasic
Function SetInternetClockIsEnabled (internetclockenabled As Boolean) As Boolean
```

#### Parameters 

internetclockenabled 

[<u>Boolean</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean) – If it is True CUEunit will start to synchronize the RTC clock with the internet clock automatically every 12 hours. If it is False CUEunit will stop synchronizing the RTC clock with the internet clock. 

Note: 

For synchronization must be NTP servers set correctly. Command SetNTPServers or AdminWeb can be used for setting NTP server names. 

#### Return value 

[<u>Boolean</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean). Function returns true 

# SetLocalTime

This function sets the time in the unit and the unit’s RTC.** ** 

#### Syntax 

```visualbasic
Function SetLocalTime(newtime As Time) As Boolean
```

#### Parameters 

newtime 

[<u>Time</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Time) – It is a new time in the current time zone. 

#### Return value 

[<u>Boolean</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean). The function returns False if parameter newtime is not valid otherwise returns True. 

# SetNTPServers

This function sets the NTP server’s names in the CUEunit.** ** 

#### Syntax 

```visualbasic
Function SetNTPServers(ntpserver1 As Text, Optional ntpserver2 As Text := "") As Boolean
```

#### Parameters 

ntpserver1 

[<u>Text</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text) – domain name or IP address of the ntpserver1. 

ntpserver2 

[<u>Text</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text) – domain name or IP address of the ntpserver2. 

#### Return value 

[<u>Boolean</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean). Function returns true 

# SetTimeZone

This function sets the time zone in the unit.** ** 

#### Syntax 

```visualbasic
Function SetTimeZone (timezoneid As Text) As Boolean
```

#### Parameters 

timezoneid 

[<u>Text</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text) – identification of the time zone. 

#### Return value 

[<u>Boolean</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)

***True*** – time zone specified by timezoneid parameter was set successfully. 

***False*** – parameter timezoneid is not valid. 

# SyncTimeWithInternetClock

This function synchronizes the RTC clock in the CUEunit with the internet clock immediately. For synchronization must be NTP servers set correctly. Command SetNTPServers or AdminWeb can be used for setting NTP server names. 

#### Syntax 

```visualbasic
Function SyncTimeWithInternetClock() As Boolean
```

#### Return value 

[<u>Boolean</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean) This function returns True on success or False if an error occurs. The function GetLastError returns the error number. The errors that can happen: [<u>230</u>](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#230), [<u>231</u>](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#231), [<u>232</u>](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#232), [<u>233</u>](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#233)<u>.</u> 

# TimeStructureToTime 

This function returns Time represented by sourcetime structure _TimeStructure. 

#### Syntax 

```visualbasic
Function TimeStructureToTime( 
  sourcetime As _TimeStructure, 
  ByRef destinationtime As Time) 
As Boolean
```

#### Parameters 

sourcetime 

[<u>_TimeStructure</u>](/wiki/spaces/CVCHELP/pages/512327880/Time#_TimeStructure) It is a time structure to be converted from. 

destinationtime 

[<u>Time</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Time) It is time to be converted to. 

#### Return value 

[<u>Boolean</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean) It is True on success or False if an error occurs. The function GetLastError returns the error number. 

# TimeToTimeStructure

This function converts sourcetime to destinationtime structure _TimeStructure. 

#### Syntax 

```visualbasic
Function TimeToTimeStructure( 
  sourcetime As Time, 
  ByRef destinationtime As _TimeStructure) 
As Boolean
```

#### Parameters 

sourcetime 

[<u>Time</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Time) It is time to be converted from. 

destinationtime 

[<u>_TimeStructure</u>](/wiki/spaces/CVCHELP/pages/512327880/Time#_TimeStructure). It is a time structure to be converted to. 

#### Return value 

[<u>Boolean</u>](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean) It is True on success or False if an error occurs. The function GetLastError returns the error number. 

# _TimeStructure

This structure is predefined in the firmware of all units, which supports time functions with _TimeStructure. 

#### Syntax 

```visualbasic
Structure _TimeStructure 
  Global Var Year As Long 
  Global Var Month As Byte 
  Global Var Day As Byte 
  Global Var DayOfWeek As Byte 
  Global Var Hour As Byte 
  Global Var Minute As Byte 
  Global Var Second As Byte 
  Global Var MicroSecond As Long 
End Structure
```

#### Predefined constants for DayOfWeek 

|  |  |  |
| --- | --- | --- |
| Name | Value | Description |
| _DAYOFWEEK_MONDAY | 1 | Monday |
| _DAYOFWEEK_TUESDAY | 2 | Tuesday |
| _DAYOFWEEK_WEDNESDAY | 3 | Wednesday |
| _DAYOFWEEK_THURSDAY | 4 | Thursday |
| _DAYOFWEEK_FRIDAY | 5 | Friday |
| _DAYOFWEEK_SATURDAY | 6 | Saturday |
| _DAYOFWEEK_SUNDAY | 7 | Sunday |

# _TimeZoneInfo

This structure is predefined in the firmware of all units, which supports time functions with _TimeZoneInfo. 

#### Syntax 

```visualbasic
Global Structure _TimeZoneInfo		
	Var ZoneId As Text[4]	
	Var ZoneName As Text[100]	
End Structure		
```