Time Minutes Seconds Formatting

Discuss topics related to the plugins and uses for MLServer beta
chuck99z28
Intermediate
Intermediate
Posts: 346
Joined: Mon Aug 27, 2012 2:10 pm
Contact:

Time Minutes Seconds Formatting

Postby chuck99z28 » Sat Apr 18, 2015 1:19 pm

How can I format the currentminute and currentsecond variable so that it has the leading "0" as it does in the currenthms variable?

I needed to use zulu time for a display, so I created a Scheduled task to take currenthourmilitary and add one and save it as currenthourmilitaryzulu.

Then I'm using {{currenthourmilitaryzulu}}:{{currentminute}}:{{currentsecond}} to format the time.

But the currentminute and currentsecond variable don't have the leading 0 when the time is 1-9 so it looks funny. I'm not sure how to do a "if currentminute is a single char add a leading zero" statement.

Thanks

User avatar
CinemarDave
Site Admin
Site Admin
Posts: 10535
Joined: Fri Feb 07, 2003 8:56 am
Location: Planet Earth
Contact:

Re: Time Minutes Seconds Formatting

Postby CinemarDave » Sun Apr 19, 2015 11:33 am

In the same scheduled task where you are creating the {{currenthourmilitaryzulu}} variable add in the command

Strings|Right~currentminseczulu~{{currenthms}}~6

This will create a {{currentminseczulu}} variable that has your zero padded minutes and seconds.

Your label will then become {{currenthourmilitaryzulu}}{{currentminseczulu}}

chuck99z28
Intermediate
Intermediate
Posts: 346
Joined: Mon Aug 27, 2012 2:10 pm
Contact:

Re: Time Minutes Seconds Formatting

Postby chuck99z28 » Sun Apr 19, 2015 12:31 pm

Thanks.
I ended up just doing the minutes with Strings and used a separate automation rule for then the currentminute changed.
Otherwise I'd just update once and hour.


Return to “MLServer Questions & Answers”

Who is online

Users browsing this forum: No registered users and 1 guest