> For the complete documentation index, see [llms.txt](https://ubtechedu.gitbook.io/chinese/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ubtechedu.gitbook.io/chinese/arduino-language/functions/time/millis.md).

# millis()

返回MCU运行当前程序从开始到现在的毫秒数

### 返回

| 参数     | 描述                       |
| ------ | ------------------------ |
| number | 返回从运行当前程序开始的毫秒数（无符号长整数）。 |

### 例子 <a href="#li-zi" id="li-zi"></a>

```c
unsigned long time;
 
void setup(){
     Serial.begin(9600)；
}
void loop(){
serial.print("Time:");
time = millis();
//打印从程序开始到现在的时间
serial.println(time);
//等待一秒钟，以免发送大量的数据
     delay(1000);
}
```

### 提示 <a href="#ti-shi" id="ti-shi"></a>

注意，参数 millis 是一个无符号长整数，试图和其他数据类型（如整型数）做数学运算可能会产生错误。 \
当中断函数发生时，millis()的数值将不会继续变化。

这个数字将在约50天后溢出（归零）。
