pxt-calliope/docs/reference/input/running-time.md

32 lines
629 B
Markdown
Raw Normal View History

2016-03-25 16:47:20 -07:00
# Running Time
Find how long it has been since the program started.
2016-03-25 16:47:20 -07:00
```sig
input.runningTime();
```
### Returns
2017-03-16 07:57:41 -07:00
* the [Number](/types/number) of milliseconds since the program started.
(One second is 1000 milliseconds.)
2016-03-25 16:47:20 -07:00
### Example: elapsed time
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-25 16:47:20 -07:00
```blocks
input.onButtonPressed(Button.B, () => {
let now = input.runningTime()
basic.showNumber(now)
})
2016-03-25 16:47:20 -07:00
```
### See also
2016-04-13 08:27:45 -07:00
[show number](/reference/basic/show-number), [pause](/reference/basic/pause)
2016-03-25 16:47:20 -07:00