> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superoffice.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Time data type

**Time** is a complex data type representing the time of the day in hours, minutes, and seconds. The default value is now. ISO 8601 uses the 24-hour clock system.

Format: hh:mm:ss

```crmscript! theme={null}
Time t;
print(t.toString());
```

This will print the current time.

<Note>
  You can create arrays of any data type to store more than one value at the same time like this: `String[] s1;`. For a given array, all items must be of the same type. Read more about [looping and accessing array items][1] in the fundamentals section.
</Note>

[1]: ../../fundamentals/arrays

## Constructors

### Time Time(Time time)

Pass a `Time` object to copy into a new object.

```crmscript! theme={null}
Time t;
Time prev = Time(t);
printLine(prev.toString());
```

### Time Time(String time)

Pass a `String` containing a timestamp on format **HH:MM:SS**. The constructor will parse the text and create a `Time` object.

```crmscript! theme={null}
String noon = "12:00:00";
Time lunch = Time(noon);
Time dailyMeeting = Time("08:00:00");
printLine(lunch.toString() + "\n" + dailyMeeting.toString());
```

## Time as strings

### String toString()

`toString()` is one of the most frequently used methods, typically when you are going to output something. It returns a string representation of a Time object.

```crmscript theme={null}
Time t;
String s = t.toString();
```

## Setting and updating time

Hours, minutes, and seconds are set to the exact value provided as an Integer input parameter.

### Void setHour(Integer hour)

`setHour()` will overwrite the current time and set hours to the given number \[0-23].
The parameter granularity is *hours*.

```crmscript theme={null}
Time t;
t.setHour(14);
```

### Void setMin(Integer min)

`setMin()` will overwrite the current time and set minutes to the given number \[0-59].
The parameter granularity is *minutes*.

```crmscript theme={null}
Time t;
t.setMin(37);
```

### Void setSec(Integer sec)

`setSet()` will overwrite the current time and set seconds to the given number \[0-59].
The parameter granularity is *seconds*.

```crmscript theme={null}
Time t;
t.setSec(0);
```

## Retrieving properties of time

You can retrieve the hour, minutes, and seconds of the current time.

### Integer getHour()

`getHour()` returns the hour portion of the time as an Integer.

```crmscript! theme={null}
Time t;
print(t.getHour().toString());
```

### Integer getMin()

`getMin()` returns the minutes portion of the time as an Integer.

```crmscript! theme={null}
Time t;
print(t.getMin().toString());
```

### Integer getSec()

`getSec()` returns the seconds portion of the time as an Integer.

```crmscript! theme={null}
Time t;
print(t.getSec().toString());
```

## No value

Before a Time object is initialized, it has no value. This is commonly written as NULL, NUL, or NIL in other programming languages.

CRMScript automatically initializes Time objects when declared to the current time. Thus this situation is uncommon. However, it is a good habit to always test that you have a value before using it.

### Bool isNull()

`isNull()` will return **true** if it has no value and **false** if it does.

```crmscript! theme={null}
Time t;
print(t.isNull().toString());
```


## Related topics

- [DateTime data type](/en/automation/crmscript/datatypes/datetime-type.md)
- [Initialize Time Zone Data](/en/api/reference/restful/agent/timezone_agent/initialize-time-zone-data.md)
- [Update Time Zone Data](/en/api/reference/restful/agent/timezone_agent/update-time-zone-data.md)
- [Operators and data types](/en/api/search/find-selection/operators.md)
- [Generic data type](/en/automation/crmscript/datatypes/generic-type.md)
- [Enum values for TimeKeepingType](/en/database/tables/enums/timekeepingtype.md)
