# Timer

### [timer function](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/libc/posix/posix-timer?id=timer-%e5%87%bd%e6%95%b0) <a href="#timer-han-shu" id="timer-han-shu"></a>

![image-20220419112531014](https://www.rt-thread.org/document/site/rt-thread-version/rt-thread-standard/programming-manual/libc/figures/menuconfig_timer.png)

1. Just turn on the timer in menuconfig
2. In user code, you can use `<sys/time.h>` the header files provided by these timers to program

```c
#include <sys/time.h>
#include <stdio.h>

int main(void)
{
    time_t sec;
    time_t ret;
    time_t timestamp = 1609459200;
    ret = time(&sec);

    if(ret != sec)
    {
        return -1;
    }
    if(ret != timestamp)
    {
        return -1;
    }
    return 0;
}copymistakeCopy Success
```

<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.aic-eec.com/recommended_by_aic/rt-thread-university-program/components/posix-standard/timer.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
