Workshop › Minesweeper › Step 23 of 26
The clock starts at the first click, not when the page loads (that would punish looking at the board). We keep the start time; the seconds on screen are worked out from it while drawing.
```js
let startTime
startTime = 0
state = 'playing'
startTime = now
const seconds = state === 'ready' ? 0 : Math.floor((now - startTime) / 1000)
ctx.textAlign = 'right'
ctx.fillText('⏱ ' + seconds, canvas.width - 10, TOP / 2)
```startTime is set on the first reveal, where the game starts.let state ..., write let startTime; in newGame, startTime = 0.reveal, under state = 'playing', write startTime = now.draw, under const flags, write const seconds ...; under the 💣 line write the two clock lines.Skills: Game states, The game loop
← What time is it? Stop the clock →