2016-03-26 00:47:20 +01:00
|
|
|
# Running Time
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
Find how long it has been since the program started in milli-seconds.
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
```sig
|
|
|
|
input.runningTime();
|
|
|
|
```
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## Returns
|
2016-03-26 00:47:20 +01:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
* the [Number](/types/number) of milliseconds since the program started.
|
2016-05-23 21:45:14 +02:00
|
|
|
(One second is 1000 milliseconds.)
|
2016-03-26 00:47:20 +01:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## Example: elapsed time
|
2016-03-26 00:47:20 +01:00
|
|
|
|
2016-05-23 21:45:14 +02:00
|
|
|
When you press button `B` on the microbit, this
|
|
|
|
program finds the number of milliseconds since the program started
|
|
|
|
and shows it on the [LED screen](/device/screen).
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
```blocks
|
2022-08-10 18:36:19 +02:00
|
|
|
input.onButtonEvent(Button.B, input.buttonEventClick(), () => {
|
2016-05-23 21:45:14 +02:00
|
|
|
let now = input.runningTime()
|
|
|
|
basic.showNumber(now)
|
|
|
|
})
|
2016-03-26 00:47:20 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## See also
|
2016-03-26 00:47:20 +01:00
|
|
|
|
2016-04-13 17:27:45 +02:00
|
|
|
[show number](/reference/basic/show-number), [pause](/reference/basic/pause)
|
2016-03-26 00:47:20 +01:00
|
|
|
|