---
name: "elftc_set_timestamps"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/elftc_set_timestamps"
---

# elftc\_set\_timestamps(3)

set file timestamps

## NAME

**elftc\_set\_timestamps** – set file timestamps

## LIBRARY

library “libelftc”

## SYNOPSIS

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

*int*\

**elftc\_set\_timestamps**(*const char \*filename*, *struct stat \*sb*);

## DESCRIPTION

The **elftc\_set\_timestamps**() function is used to set the access and modified time stamps on a file based on the contents of a *struct stat* descriptor.

Argument *filename* names an existing file in the file system.

Argument *sb* points to structure of type *struct stat* populated by a prior call to [fstat(2)](/fstat/2.md) or [stat(2)](/stat/2.md).

## IMPLEMENTATION NOTES

This function will invoke the high-resolution [utimes(2)](/utimes/2.md) system call if the underlying operating system supports it. On operating systems lacking support for [utimes(2)](/utimes/2.md), the function will use lower resolution [utime(2)](/utime/2.md) system call.

## EXAMPLES

To set the access and modified times for a new file to those of an existing file, use:

```
struct stat sb;
const char *existing_filename, *new_filename;
if (stat(existing_filename, &sb) < 0)
	err(EXIT_FAILURE, "stat failed");
if (elftc_set_timestamps(new_filename, &sb) < 0)
	err(EXIT_FAILURE, "timestamps could not be set");
```

## SEE ALSO

[fstat(2)](/fstat/2.md), [stat(2)](/stat/2.md), [utime(2)](/utime/2.md), [utimes(2)](/utimes/2.md)
