---
name: "krb5_format_time"
section: "3"
platform: "linux"
package: "heimdal-dev"
version: "7.8.git20221117.28daf24+dfsg-9+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/krb5_format_time"
---

# krb5\_format\_time(3)

Kerberos 5 time handling functions

## NAME

**krb5\_timeofday**, **krb5\_set\_real\_time**, **krb5\_us\_timeofday**, **krb5\_format\_time**, **krb5\_string\_to\_deltat** – Kerberos 5 time handling functions

## LIBRARY

Kerberos 5 Library (libkrb5, -lkrb5)

## SYNOPSIS

**#include \<krb5.h\>**

krb5\_timestamp;

krb5\_deltat;

*krb5\_error\_code*\

**krb5\_set\_real\_time**(*krb5\_context context*, *krb5\_timestamp sec*, *int32\_t usec*);

*krb5\_error\_code*\

**krb5\_timeofday**(*krb5\_context context*, *krb5\_timestamp \*timeret*);

*krb5\_error\_code*\

**krb5\_us\_timeofday**(*krb5\_context context*, *krb5\_timestamp \*sec*, *int32\_t \*usec*);

*krb5\_error\_code*\

**krb5\_format\_time**(*krb5\_context context*, *time\_t t*, *char \*s*, *size\_t len*, *krb5\_boolean include\_time*);

*krb5\_error\_code*\

**krb5\_string\_to\_deltat**(*const char \*string*, *krb5\_deltat \*deltat*);

## DESCRIPTION

**krb5\_set\_real\_time** sets the absolute time that the caller knows the KDC has. With this the Kerberos library can calculate the relative difference between the KDC time and the local system time and store it in the *context*. With this information the Kerberos library can adjust all time stamps in Kerberos packages.

**krb5\_timeofday**() returns the current time, but adjusted with the time difference between the local host and the KDC. **krb5\_us\_timeofday**() also returns microseconds.

**krb5\_format\_time** formats the time *t* into the string *s* of length *len*. If *include\_time* is set, the time is set include\_time.

**krb5\_string\_to\_deltat** parses delta time *string* into *deltat*.

## SEE ALSO

[gettimeofday(2)](/gettimeofday/2.md), [krb5(3)](/krb5/3.md)
