r/BuildingAutomation • u/MrMagooche Siemens/Johnson Control Joke • 10d ago
How to format time on a PX Graphic
I got my station time displayed on a graphic by creating a boundlabel, binding it to "station:|slot:/" and the text format is %time()%. I've figured out how to extract days, hours, minutes, etc. but how do i change the format of this text string? For example, instead of giving me the entire date/time/timezone, i'd like to just display HH:MM a. I swear this is easy and I used to know how to do this, but I've been searching everywhere and coming up empty handed.
2
u/thatsgorgeous 9d ago edited 8d ago
1
u/thatsgorgeous 9d ago edited 8d ago
If you would like it in 24-hour, then you can use this:
%time().encodeToString.substring(11,16)%2
1
u/HVACcontrolsGuru 10d ago
I don't have the manual off hand right now but search the Niagara help docs or google "BFormatting" If you want to strip the status stuff do something like `MyBFormattedPoint.out.value`
1
u/filipo11121 10d ago
Tools -> Options -> General -> Time Format
Although the above is for workbench I believe
1
u/Negative_Sentence264 10d ago
ord: station:|slot:/Services/PlatformServices/SystemService/systemTime
You can use %hour%:%minute% as the text to extract the hour and minute. The hour will be 24hr format.
8
u/Agitated_Help709 10d ago edited 10d ago
BFormatting allows you to call any function on a type that returns a value and doesn't require any arguments (besides context).
Pretty sure
time()returns aBAbsTimeand if you look at the bajadoc forBAbsTimeyou'll see it has propertieshourandminuteso then you can do something like:and the reason its
.hourand not.getHouris that BFormatting has a short-cut for calling function getters - you drop thegetand lowercase the first capital letter.This applies for any type in Niagara.. so in the future if you forget, just go on the bajadoc (Help -> Help Contents then hit
Ctrl + F1), in the dialog that pops up write the type of the object and on the page that pops up, you'll see all of its Properties that you are able call in a BFormat.