Need help: Timer

So most people who would answer this question already know I’m making an app for class.
The game will have a challenge mode that I’m coding, and it will count down. You will have 1 minute to complete as many questions as you can. How would I make this timer?
Would it be something like

t = 60 * 60
function draw()
    t= t - 1
    if  t== 0 then
    print("you lose")
    end
end

I was thinking of doing this but is there a more convenient way to do it?

@JessicGriffin this approach works if your program runs at a constant of 60fps

but to point something out, you defined the time as 1 hour instead of 1 minute

function setup()
   startT = string.format("%d",ElapsedTime)
    countTo = 3
end

function draw()
    background(0, 0, 0, 255)
    fontSize(32)
    counter = string.format("%d",ElapsedTime) - startT
    if counter <=countTo then
        text(counter,WIDTH/2,HEIGHT/2)
    elseif counter > countTo then
        text("Finished",WIDTH/2,HEIGHT/2)
    end 
end

Id counts up but it will be easy to switch it to counting down. ElapsedTime is very useful for this sort of thing.

Happy timing!

Timer = class()

function Timer:init(interval,callback)
    self.interval = interval
    self.callback = callback
    self.time = 0
    self.occurances = 0
    self.paused = false
end

function Timer:update()
    if self.paused ~= true then
        self.time = self.time + DeltaTime
        if self.time >= self.interval then
            self.occurances = self.occurances + 1
            self.time = 0
            if type(self.callback) == "function" then
                self.callback(self.occurances)
            end
            return true
        else
            return false
        end
    end
end

function Timer:reset()
    self.time = 0
    self.occurances = 0
end

function Timer:pause()
    self.paused = true
end

function Timer:resume()
    self.paused = false
end

function Timer:isPaused()
    return self.paused
end

function Timer:getTime()
    return self.time
end

function Timer:getCount()
    return self.occurances
end

Wow, thanks everyone xD So many different ways .-.

@JessicGriffin Here’s a countdown timer.


displayMode(FULLSCREEN)

function setup()
    fontSize(50)
    et=ElapsedTime+1
    delay=15
end

function draw()
    background(40,40,50)
    fill(255)
    t=et+delay-ElapsedTime
    if t>1 then
        text(string.format("%d",t),WIDTH/2,HEIGHT/2)
    else
        text("Times up.",WIDTH/2,HEIGHT/2)
    end 
end