What is the most efficient way to obtain a formatted date string within? Occasionally in directives to executables, I’d like to specify names of output logs and such based on the current date.
In UNIX I’d embed something like: date +%Y%m%d
In PowerShell: (get-date -Uformat “%Y%m%d”)
This gets the results I want in BigFix: (current year as string) & (current month as two digits as string) & (current day_of_month as two digits as string)
You are not missing anything, there are no formatting templates.
Here are 2 code fragments that I keep around - one for date and one for date/time - that I have to format to my liking.
Date format:
(year of it as string & “/” & month of it as two digits & “/” & day_of_month of it as two digits) of current date
2013/09/17
Time format:
((year of it as string & “/” & month of it as two digits & “/” & day_of_month of it as two digits) of date(local time zone) of it & " "& (two digit hour of it as string & “:” & two digit minute of it as string & “:” & two digit second of it as string) of time (local time zone) of it) of now
(day_of_month of date (local time zone) of now as two digits as string) & “-” & ((month of date (local time zone) of now) as string) & “-” & (year of date(local time zone) of now as string)