To obtain the last n characters of a string use {(substr "string" -n)}
To truncate the last n characters of a string use (substr "string" 0 -n)}
ftime
"Ftime" expressions are used for date and time formatting. The generic form is
{(ftime "fmt" "when")}
{(ftime fmt="fmt" when="when")}
where fmt is a formatting string and when is the time to be formatted. The arguments can be in either order and may use the optional "fmt=" and "when=" labels.
05 février 2025 à 21h29
2025-02-05 21:29
2025
21:29:44
06 février 2025 à 00h00
2025-02-04
2025-02-12
03/05/25
lun.10 févr.
The fmt parameter is whatever is given by "fmt=", the first parameter containing a '%', or else the site's default. The formatting codes are described at http://php.net/strftime. In addition to those, '%F' produces ISO-8601 dates, and '%s' produces Unix timestamps.
Some common formatting strings:
%F # ISO-8601 dates "2025-02-05"
%s # Unix timestamp "1738787384"
%H:%M:%S # time as hh:mm:ss "21:29:44"
%m/%d/%Y # date as mm/dd/yyyy "02/05/2025"
"%A, %B %d, %Y" # in words "mercredi, février 05, 2025"
The when parameter understands many different date formats. The when parameter is whatever is given by "when=", or whatever parameter remains after determining the format parameter. Some examples:
2007-04-11 # ISO-8601 dates
20070411 # dates without hyphens, slashes, or dots
2007-03 # months
@1176304315 # Unix timestamps (seconds since 1-Jan-1970 00:00 UTC)
now # the current time
today # today @ 00:00:00
yesterday # yesterday @ 00:00:00
"next Monday" # relative dates
"last Thursday" # relative dates
"-3 days" # three days ago
"+2 weeks" # two weeks from now
Note: If you want to convert a Unix timestamp you must prefix with the @. Thus, "{(ftime "%A, %B %d, %Y" @1231116927)}".
The when parameter uses PHP's strtotime(approuver les sites) function to convert date strings according to the GNU date input formats; as of this writing it only understands English phrases in date specifications.
The variable $FTimeFmt can be used to override the default date format used by the "ftime" function. The default $FTimeFmt is $TimeFmt.
strlen
The "strlen" expression returns the length of a string. The first argument is the string to be measured.
{(strlen "{$:Summary}")}
32
rand
The "rand" expression returns a random integer. The first argument is the minimum number to be returned and the second argument is the maximum number to be returned. If called without the optional min, max arguments rand() returns a pseudo-random integer between 0 and RAND_MAX. If you want a random number between 5 and 15 (inclusive), for example, use (rand 5 15).
{(rand)}
{(rand 1 99)}
1038232054
39
mod
The advanced "mod" expression returns the modulo (remainder) of the division of two numbers. It may be used in advanced PageList templates together with {$$PageCount} to insert markup every (modulo) entries, for example to create alternate styled "zebra" table rows, or to insert a line/row break. (See also PageLists, WikiStyles and ConditionalMarkup.)
STRING AND FORMATTING OPERATIONS
string and formatting operations
ucfirst / ucwords
The "ucfirst" expression converts to uppercase the first character of the string, and "ucwords", the first character of each word. The first argument is the string to be processed.
String and formatting operations
String And Formatting Operations
pagename
The "pagename" expression builds a pagename from a string. The first argument is the string to be processed.
{(pagename "{$:Summary}")}
PmWiki.StringAndFormattingOperations
asspaced
The "asspaced" expression formats wikiwords. The first argument is the string to be processed.
{(asspaced "{$FullName}")}
Pm Wiki.Markup Expressions
Nesting expressions
Markup expressions can be nested. Omit the curly braces for the inner expressions:
{(tolower (substr "Hello World" 2))}
llo world
Notes
For PmWikis version 2.2.33 or older, the string-processing expressions may not work properly on multibyte UTF-8 characters. Newer versions should work fine.