April 18, 2007
Formatting Options
You can add formatting to any data tag using the
format= option. The main formatting commands are described below.
Date and Time
Dates and times use a format string
as described below. You can use any combination of formatting options and text in the format string. If the format string contains spaces, you will need to enclose it in either single or double quotes.
Date Formatting Options
Code
| Meaning
| Examples
|
%a
| Abbreviated weekday name.
| Tue, Thu
|
%A
| Full weekday name.
| Tuesday, Thursday
|
%b
| Abbreviated month name
| Jan, Aug
|
%B
| Full month name.
| January, August
|
%c
| Date and time.
| Tue Apr 3 14:53:38 2007
|
%d
| Day of month.
| 3
|
%j
| Day of year.
| 093
|
%m | Month. | 1, 8 |
%U | Week of year (weeks starting Sunday). | 13
|
%W | Week of year (weeks starting Monday). | 13 |
%x | Date (mm/dd/yy). | 04/03/07 |
%y | Year. | 07 |
%Y | Year with century. | 2007 |
Time Formatting Options
Code
| Meaning
| Examples
|
%H
| Hour (24-hour clock).
| 11, 23
|
%I
| Hour (12-hour clock).
| 11, 11
|
%M
| Minute.
| 03, 29
|
%p
| AM or PM.
| AM, PM
|
%S
| Second.
| 15, 59
|
%X
| Time.
| 14:53:38
|
Some Examples
Code
| Result
|
%A, %B %d
| Monday, April 09 |
%I:%M %p
| 08:57 PM |
%A, %B %d %Y %I:%M %p
| Monday, April 09 2007 08:57 PM |
%Y-%m-%d
| 2007-04-09
|
Example: [
post.date format="%I:%M %p"]
Text
Multiple text formatting options can be applied by separating the commands with commas. The formatting commands are applied in the order they are listed. Example: [
post.text format="first=100,underscore,lower"].
Option
| Description
|
left=n
| Returns the first n characters of the text.
|
right=n
| Returns the last n characters of the text.
|
first=n
| Returns the first n words of the text.
|
last=n
| Returns the last n words of the text.
|
trim
| Removes any leading and trailing spaces.
|
trim=s
| Removes any leading or trailing instances of string s.
|
lower
| Converts text to lower case.
|
upper | Converts text to upper case. |
words | Returns the number of words in the text. |
letters | Returns the number of letters in the text. |
nospace | Removes any spaces from the text. |
underscore | Convert any spaces in the text to underscores. |
Numbers
Number formatting works by placing the formatted value into a string containing both formatting options and text.
Option
| Description
|
%d
| Signed integer decimal.
|
%i
| Signed integer decimal.
|
%o
| Unsigned octal.
|
%u
| Unsigned decimal.
|
%x
| Unsigned hexadecimal (lower case).
|
%X
| Unsigned hexadecimal (upper case).
|
%e
| Floating point exponential (lower case).
|
%E | Floating point exponential (lower case). |
%f | Floating point decimal format.
|
%F
| Floating point decimal format. |
%g | Variable floating point format. |
%G | Variable floating point format. |
%s | Default representation. |
%% | % symbol. |
As an example, you could have [
post.words format="There are %d words in this post."]
Each of the numeric formatting options can take a number of flags:
Flag
| Description
| Example
|
0
| Zero fill the result.
| %0d
|
-
| Left-adjust the result
| %-d
|
| (Space) Leave a space before a positive result.
| % d
|
+
| Always show a leading + or -.
| %+d
|
Posted by: Pixy Misa at
09:34 AM
| No Comments
| Add Comment
Post contains 430 words, total size 13 kb.
Comments are disabled.
Post is locked.
20kb generated in CPU 0.4227, elapsed 2.6335 seconds.
29 queries taking 2.6255 seconds, 51 records returned.
Powered by Minx 1.1.6c-pink.