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

# CAPLfunctionTimeToString

# TimeToString

[Valid for](../../../Shared/FeatureAvailability.md): CANoe DE • CANoe:lite DE • CANoe4SW DE • CANoe4SW:lite DE

## Function Syntax

```plaintext theme={null}
long TimeToString(int64 timeNS, char buffer[]);
```

## Description

Converts a timestamp or a duration (given in nanoseconds) into a string in the format `days:hours:minutes:seconds,microseconds`. Hours, minutes and seconds are always with two digits; microseconds are with six digits so they show the fraction of the second.

## Parameters

* **timeNS**: Time/duration in nanoseconds. This could be a timestamp of a frame, the time given by [timeNowInt64](CAPLfunctionTimeNowNS.md), or a time measured with the [CAPLProfiler class](../../ObjectOrientedProg/CAPLfunctionsOOPCAPLProfiler.md).

* **buffer**: Receives the string. Must be at least 18 characters long (more if the duration is >= 10 days).

## Return Values

* **0**: Success
* **-1**: Error, e.g. buffer too small.

## Example

```plaintext theme={null}
on sysvar MySysVar
{
  char timeString[20];
  TimeToString(timeNowInt64(), timeString);
  Write("MySysVar was changed at simulation time %s", timeString);
}
```

[convertTimestamp](CAPLfunctionConvertTimestamp.md) • [getLocalTimeString](CAPLfunctionGetLocalTimeString.md)
