2020-10-23 15:25:05 +00:00
|
|
|
|
created: 20201020102735123
|
2023-05-06 10:44:22 +00:00
|
|
|
|
modified: 20230226135641976
|
2020-10-23 15:25:05 +00:00
|
|
|
|
tags: [[Operator Examples]] [[format Operator]]
|
|
|
|
|
title: format Operator (Examples)
|
|
|
|
|
type: text/vnd.tiddlywiki
|
|
|
|
|
|
|
|
|
|
These examples use the tiddler HelloThere.
|
|
|
|
|
|
|
|
|
|
Created date with no format string specified:
|
|
|
|
|
<<.operator-example 1 "[[HelloThere]get[created]format:date[]]">>
|
|
|
|
|
|
|
|
|
|
Created date with a format string supplied as operator parameter:
|
|
|
|
|
<<.operator-example 2 "[[HelloThere]get[created]format:date[DDth MMM YYYY]]">>
|
|
|
|
|
|
|
|
|
|
Modified date shown as a relative date:
|
|
|
|
|
<<.operator-example 3 "[[HelloThere]get[modified]format:relativedate[]]">>
|
2021-05-24 18:28:43 +00:00
|
|
|
|
|
2023-05-06 10:44:22 +00:00
|
|
|
|
Get the date and time exactly 24 hours (86,400,000 milliseconds) from now:
|
|
|
|
|
<<.operator-example 4 "[<now [UTC]YYYY0MM0DD0hh0mm0ss0XXX>format:date[TIMESTAMP]add[86400000]format:timestamp[DDth mmm YYYY 0hh:0mm:0ss]]">>
|
|
|
|
|
|
2021-05-24 18:28:43 +00:00
|
|
|
|
A tiddler title with spaces formatted as a title list:
|
2023-05-06 10:44:22 +00:00
|
|
|
|
<<.operator-example 5 """[[Hello There]format:titlelist[]]""">>
|
2021-05-24 18:28:43 +00:00
|
|
|
|
|
2022-09-02 17:15:45 +00:00
|
|
|
|
All tiddler titles tagged with <<tag TableOfContents>> formatted as a title list:
|
2023-05-06 10:44:22 +00:00
|
|
|
|
<<.operator-example 6 """[tag[TableOfContents]format:titlelist[]]""">>
|
2021-05-24 18:28:43 +00:00
|
|
|
|
|
2022-09-02 17:15:45 +00:00
|
|
|
|
A JSON string formatted as JSON – note how the JSON string is normalised to remove the duplicated properties:
|
2023-05-06 10:44:22 +00:00
|
|
|
|
<<.operator-example 7 """[[{"one":"first","one":"another","two":"second"}]format:json[]]""">>
|
2022-09-02 17:15:45 +00:00
|
|
|
|
|
2021-05-24 18:28:43 +00:00
|
|
|
|
<<.tip "To create a string to save a [[title list|Title List]] into a list field, use `format:titlelist[]` with the [[join operator|join Operator]]">>
|
2023-05-06 10:44:22 +00:00
|
|
|
|
<<.operator-example 8 """[tag[TableOfContents]format:titlelist[]join[ ]]""">>
|
2021-05-24 18:28:43 +00:00
|
|
|
|
For example, to save titles tagged `TableOfContents` to the titles field of the tiddler [[format titlelist test]]:
|
|
|
|
|
|
|
|
|
|
<$macrocall $name='wikitext-example-without-html'
|
2023-05-06 10:44:22 +00:00
|
|
|
|
src='<$button>Try it
|
2021-05-24 18:28:43 +00:00
|
|
|
|
<$action-setfield $tiddler="format titlelist test" titles={{{ [tag[TableOfContents]format:titlelist[]join[ ]] }}}/>
|
|
|
|
|
</$button>'/>
|