Help needed with Date Format to correctly show Tag as Full Date

Hello everyone,
I need some help to correct my Tiddler and Template Tiddler which is generally working, but I woould like the due-date field to show as a tag ( format 0DDst MMM YYYY ) in the resultant tiddler - if possible. Can anyone solve this?
I have attached json tiddlers so that you can try them out at https://tiddlywiki.com/
Template

<$details summary="Summary"open="no" class="success">
<table>
<tr align="left" valign="top"><th>object-type</th><th>what</th><th>who</th><th>date</th><th>when</th><th>where</th><th>why</th></tr>
<tr align="left" valign="top"><td>{{!!object-type}}</td><td>{{!!what}}</td><td>{{!!who}}</td><td><$view field=due-date format=date template="[UTC]DDth MMM YYYY" /></td><td>{{!!when}}</td><td>{{!!where}}</td><td>{{!!why}}</td></tr>
</table>
</$details>

New Object

\define testCreate()
<$action-createtiddler $basetitle={{{ [{!!what}addsuffix[ ]addsuffix{!!who}addsuffix[ ]addsuffix{!!due-date}addsuffix[ ]addsuffix{!!when}addsuffix[ ]addsuffix{!!where}addsuffix[ ]addsuffix{!!why}] }}} $template="$:/_/my/templates/object"
what={{!!what}}
who={{!!who}}
due-date={{!!due-date}}
when={{!!when}}
where={{!!where}}
why={{!!why}}
object-type={{!!object-type}}
tags={{{ [{!!what}addsuffix[ ]addsuffix{!!who}addsuffix[ ]addsuffix{!!due-date format=date template="[UTC] 0DDth MMM YYYY"}addsuffix[ ]addsuffix{!!when}addsuffix[ ]addsuffix{!!where}addsuffix[ ]addsuffix{!!why}addsuffix[ ]addsuffix{!!object-type}] }}}
>
<$action-navigate $to=<<createTiddler-title>>/>
</$action-createtiddler>
</$set>
\end


<table>
<tr align="left" valign="top"><td><<combo-get"what">></td></tr>
<tr align="left" valign="top"><td><<combo-get"who">></td></tr>
<tr align="left" valign="top"><td><<combo-get"where">></td></tr>
<tr align="left" valign="top"><td><<combo-get"due-date">></td></tr>
<tr align="left" valign="top"><td><<combo-get"when">></td></tr>
<tr align="left" valign="top"><td><<combo-get"why">></td></tr>
<tr align="left" valign="top"><td><<combo-get"object-type">></td></tr>
</table>

<$button actions=<<testCreate>> >
Create Tiddler
</$button>

$____my_templates_object.json (588 Bytes)
$____my_buttons_new-object.json (1.6 KB)

Give this a try:

<$let fmt="[UTC]DDth MMM YYYY">
<$action-createtiddler $basetitle={{{ [{!!what}] [{!!who}] [{!!due-date}] [{!!when}] [{!!where}] [{!!why}] +[join[ ]] }}}
...
tags={{{ [{!!what}] [{!!who}] [{!!due-date}format:date<fmt>] [{!!when}] [{!!where}] [{!!why}] [{!!object-type}] +[format:titlelist[]join[ ]] }}}

Notes:

  • instead of using a sequence of addsuffix[...] operators, list each input value as a separate filter run and then use +[join[ ]] at the end to connect them together.
  • for the tags field value, use +[format:titlelist[]join[ ]] at the end to connect them together. The format:titlelist[] operator ensures that if a tag value contains spaces it will be enclosed in doubled square brackets so it won’t be treated as multiple single-word tag values
  • Note that the DDth date format does NOT have a “leading zero” option. Using 0DDth results in 0DD being processed followed by literal text “th”. This will produce 01th, 02th, and 03th as output instead 1st, 2nd and 3rd.
  • Also note that the format:date[DDth MMM YYYY] operator is using the local timezone. To use a UTC timezone requires a little trick. The issue is that you can’t embed the “[UTC]” syntax directly in the format:date[...] operator because the square brackets will interfere with the parsing of the operator’s parameter value. Instead, you need to define the format as a variable (e.g., <$let fmt="...">) before the $action-createtiddler widget, and then reference that variable in the filter syntax as format:date<fmt>

Let me know how it goes…

-e

edit: fixed missing ] as per @Scott_Sauyet’s note

Surely we could fix this, using UTC in the date format strings and in the JavaScript converting as needed into [UTC]? Maintain backwards compatibility (depricate)

  • This is one of those little niggly things that makes it harder to use tiddlywiki. Especialy when trying to deal with the somewhat fiddly timezones

I would love to see this “fixed” as the current “use a variable” workaround is awkward at best.

However, there is a backward compatibility issue because the format:date[...] parameter treats any non-formatting characters as literal text that is passed through to the resulting output.

For example, if the format string is:

{{{ [<now>format:date[Today is MMM DDth, YYYY]] }}}

then the output would be

Today is October 21st, 2025

where "Today is " has been passed through unchanged in the output.

Of course, this handling is already somewhat problematic if the literal text contains any date formatting syntax. For example:

{{{ [{!!inspected}format:date[The item passed inspection on MMM DDth, YYYY]] }}}

would result in something like this:

The item pa23ed inspection on October 21st, 2025

because the “ss” in “passed” is a date formatting code that is converted to seconds. The easy workaround for this is to simply move the literal text outside of the date format parameter, like this:

The item passed inspection on {{{ [{!!inspected}date:format[MMM DDth, YYYY]] }}}

So… what do we do about the current [UTC] date format handling? Note that this character sequence only has special meaning if it occurs at the very start of the date format parameter as in: [UTC]MMM DDth, YYYY. If it occurs anywhere else in the format parameter, it is handled as literal text.

One possible solution would be to use parentheses in place of the square brackets, so (UTC)MMM DDth, YYYY would be the same as [UTC]MMM DDth, YYYY. This would then permit the UTC handling to be used directly in the format:date[...] parameter, like this:

{{{ [{!!inspected}format:date[(UTC)MMM DDth, YYYY]] }}}

Note that there would be a backwards compatibility issue if someone has already used “(UTC)” as literal text at the start of a date format parameter, but I suspect that usage rarely (if ever) occurs since it would be very odd to display “(UTC)” when the date formatting output is using a local timezone.

Let me know if this makes sense to you…

-e

1 Like

It makes sence but then I dont think we loose much if the current [UTC] is passed through and then only a "leading UTC" is changed to [UTC] before being passed through. Because the current method demands the use of a macro to imbed [UTC] this change will not effect the current usage.

Note that there is a typo in there that will stop it from working correctly. Under tags, you will need to close [{!!why} with a final brace: [{!!why}].

tags={{{ [{!!what}] [{!!who}] [{!!due-date}format:date<fmt>] [{!!when}] [{!!where}] [{!!why}] [{!!object-type}] +[format:titlelist[]join[ ]] }}}

Hello @EricShulman
thank you for the explanation and pointing out my error (0DDth) with the date format, I’m not sure why I used that ?

Regarding your solution it worked fine after I read @Scott_Sauyet’s comment regarding the typo missing the final brace.

My thanks to everyone who showed interest in this discussion.
For those who would like to try this in their own TW, I will also add the procedure that creates the combo-boxes for the dropdowns in the new object tiddler.
Please also note that I use @telmiger’s Details Widget available here

Thanks again @EricShulman ,@Scott_Sauyet and @TW_Tones
$____my_procedures_combo-get.json (719 Bytes)
$____my_buttons_new-object.json (1.4 KB)
$____my_templates_object.json (588 Bytes)
Updated new-object.json file

2 Likes