format

format

Formats the content within the tag based on the tag parameters

Example

[%format type:'currency'%][@price@][%/format%]

Usage

Format tags are used manipulate the output of data created by Neto Template Tags. For example you can use format tags to change the way a date is displayed, trim a product name or change the case of a model number.

Printing the current time/date

The format tag allows you to print the current date / time by simply adding the word now within the tag, like so :

[%format type:'date' format:'#D #K #Y at #H:#I:#S'%]now[%/format%]

format Parameters

Name Options Description
type date, text, number, percent, currency, csv The type of format you wish to apply, each type has its own set of parameters that are specific to the type.
format Code, see chart

Works with type date and determines the output of the date format

Year
#YNumeric representation (4 digits)
#yShort numeric representation (2 digits)
Month
#MNumeric representation (04)
#mNumeric representation without leading zero (4)
#KTextual representation (April)
#kShort textual representation (Apr)
Date
#DNumeric representation (07)
#dNumeric representation without leading zeros (7)
Day
#WTextual representation (Friday)
#wShort textual representation (Fri)
Hours
#H24-hour numeric representation (04:30)
#h24-hour numeric representation without leading zeros (4:30)
#G12-hour numeric representation (09:45)
#g12-hour numeric representation without leading zeros (9:45)
Minutes
#INumeric representation (06)
#iNumeric representation without leading zero (6)
Seconds
#SNumeric representation (09)
#sNumeric representation without leading zero (9)
AM/PM
#AUppercase ante meridiem and post meridiem (AM or PM)
#uLowercase ante meridiem and post meridiem (am or pm)
Unix
#UUnix epoch time (seconds since 1970-01-01 00:00:00 GMT) given a local time
#uUnix epoch time (seconds since 1970-01-01 00:00:00 GMT) given a GMT time
Timezones
#ZNumeric representation of the timezone offset (+1000)
case upper, lower Works with type text, forces the content to either be upper or lower case
maxlength Integer Works with type text, limits the maximum amount of characters contained within the tag
wordlength Integer Works with type text, limits the maximum amount of words contained within the tag
truemaxlength Integer Works with type text, limits the maximum amount of characters contained within the tag after nohtml/rmhtml has been applied.
trim e, l, r, a Works with type text, trims out spaces depending on the value used. l & r trim out spaces to the left and right respectively, a trims out all space between text and e trims out all space between text down to the interger attached to it, so for example, trim:'e1' will trim down to 1 space, removing the potential for double spaces.
nohtml 1/0 Works with type text, when true it will escape HTML.
rmhtml 1/0 Works with type text, when true it will strip HTML.
noeol 1/0 Works with type text. Removes carriage returns from the text.
addbr 1/0 Works with type text. Converts newline characters to <br> tags.
dp Integer Works with type number, it will format the number to the specificed number of decimal places
pf String Works with type number and currency, this string will be prepended to the output. Eg. "$" or "AUD $".
tl String Works with type number, adds the string specified to the end of the number formatted
sp String Works with type number, adds the string specified at every thousand interval. Typically you would place a , here, so 10000 would be formatted as 10,000
tl_unit String Works with type number, generates a text block based on the value, so if the item is singular ie. There is one, we might print the text "item has"
tl_plural String Works with type number, generates a text block based on the value, so if the item is plural ie. There is two, we might print the text "items have"
dpno_zero 0/1 Works with type currency, a boolean that when true will remove the decimal place if the cents value is 0 or 00
add String Determine time value you would like to add to remove from current timeframe, example -1 Hour 1 day 5 min 2 month

Was this article useful?

Be notified when this page is updated. Optional.