# 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;
}
```


---

# 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://arduino.doc.skyone.host/core/time/millis.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.
