Migrated From JP Software Wiki
This article describes Date and Time functions, including parameterless functions that act as pseudo internal variables.
Pseudo internal variables
(Function definitions must be on a single line with no hard returns.)
12-hour format with am/pm
These consider noon to be 12:00 pm and midnight to be 00:00 am.
This shows the hour as 12 for times from midnight to 1 a.m.
It's also possible to define these examples as actual variables in the environment (with or without a leading underscore depending on your preference) thus avoiding the need to call them as functions with no parameters. For example (all on one line):
This article describes Date and Time functions, including parameterless functions that act as pseudo internal variables.
Pseudo internal variables
(Function definitions must be on a single line with no hard returns.)
12-hour format with am/pm
These consider noon to be 12:00 pm and midnight to be 00:00 am.
Code:
: Returns current time in 12 hour format with am/pm, no seconds
: Syntax: Echo %@now0ampm[]
now0ampm %@if[%_hour lt 13,%_hour,%@eval[%_hour-12]]:%_minute
%@if[%_hour lt 12,a,p]m
: Returns current time in 12 hour format with am/pm, with seconds
: Syntax: Echo %@nowsecampm[]
nowsecampm %@if[%_hour lt 13,%_hour,%@eval[%_hour-12]]:%_minute:%_second
%@if[%_hour lt 12,a,p]m
This shows the hour as 12 for times from midnight to 1 a.m.
Code:
: Returns current time in 12 hour format with am/pm, no seconds
: Syntax: Echo %@nowampm[]
nowampm %@if[%_hour lt 13,%@if[%_hour gt
0,%_hour,12],%@eval[%_hour-12]]:%_minute %@if[%_hour lt
12,a,p]m
It's also possible to define these examples as actual variables in the environment (with or without a leading underscore depending on your preference) thus avoiding the need to call them as functions with no parameters. For example (all on one line):
Code:
set _nowampm=`%@if[%_hour lt 13,%@if[%_hour gt 0,%_hour,12],%@eval
[%_hour-12]]:%_minute %@if[%_hour lt 12,a,p]m`