> For the complete documentation index, see [llms.txt](https://docs.aic-eec.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aic-eec.com/recommended_by_aic/rt-thread-university-program/components/posix-standard/timer.md).

# 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>
