> For the complete documentation index, see [llms.txt](https://arduino.doc.skyone.host/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://arduino.doc.skyone.host/core/time/millis.md).

# millis

## 函数原型

```cpp
unsigned long millis(void);
```

## 作用

获取 Arduino 通电后或复位后到现在的时间，单位毫秒

就类似于 Python 里的 `time.time()` ，只不过单片机不知道现在的时间，所以不是 1970 年 1 月 1 日 0 时 0 分 0 秒起至现在的总秒数，而是Arduino 通电后或复位后到现在的时间。

## 返回值

* `unsigned long` 无符号整型

  Arduino 通电后或复位后到现在的时间，单位**毫秒**

## 示例

```cpp
void setup() {
    delay(500);

    int time = millis();
    // time 约等于 500
}

coid loop() {
    return;
}
```
