Real Time HH:MM format

I want to present time in 24 hour format HH:MM.
I have tried using [[Now.getHours()]]:[[Now.getMinutes()]]

From :00 to :09 the minutes past the hour are present as a single digit HH:M

Does anyone know how to present :00 to :09 the minutes past the hour as two digits instead of one?

You’ll need to use two cases with a condition to determine if the minutes are equal to 0-9. Then in that special case you’ll use this:
0[[Now.getHours()]]:[[Now.getMinutes()]]

1 Like

Hi Nathan,

this is one you will really like:

[[Now.substr(16,5)]]

Best
Gregor

4 Likes

Not sure how this works but it does - saves creating two conditions for single and double digit HH and MM

1 Like

Exactly.

The complete “now”-string contains the correct time in hh:mm (starting at character 16 of the string and has 5 characters = substring(16,5))

1 Like

Ah great idea, Gregor. I hadn’t thought that Now would contain the zero.

Thanks - works really well.

How could i achieve the format HH:MM:SS using substring?

[[Now.substr(16,8)]]

1 Like

To achieve a real-time YYYY : MM : DD HH:MM:SS I have used:
[[Now.toISOString().substr(0,10)]] [[Now.substr(16,8)]]

What would I need to show the current time subtracted by 36 hours?

1 Like

[[(Now.addHours(-36)).toISOString().substr(0,10)]] [[(Now.addHours(-36)).substr(16,8)]]

1 Like

You can add or subtract using a positive or negative number (where n is a number):
hours .addHours(n)
minutes .addMinutes(n)
seconds .addMinutes(n)

I am currently prototyping a design where you can see when a train will arrive at each station so I would like to simulate the

‘current time’ +0mins at station A
‘current time’ +2mins at station B
‘current time’ +4mins at station C
and so on, so it look like this

Station A
12:00

Station B
12:02

Station C
12:04

Im currently using [[Now.substr(16,5)]] to pull in the current time, but im stuck on how to make it add minutes on.

Station A
[[Now.substr(16,5)]]

Station B
[[Now.addMinutes(2).substr(16,5)]]

Station C
[[Now.addMinutes(4).substr(16,5)]]

1 Like