This is a stripped-down version of a single section of Grok TiddlyWiki, optimized for fast loading and readability by search engines. Some features are missing.

For the full Grok TiddlyWiki experience, please visit the wiki version of this page.

Ex:CreatedNowButton/answer

2nd May 2021 at 11:21am
<$button set="!!created" setTo=<<now [UTC]YYYY0MM0DD0hh0mm0ssXXX>>>
    Created Now
</$button>

{{!!created}}}

(The {{!!created}} is just there so you can check your work. You can also click the info button and look on the Fields tab.)

You might be tempted to define and use the now-timestamp macro discussed earlier, but there's a gotcha awaiting the unwary:

\define now-timestamp() <<now [UTC]YYYY0MM0DD0hh0mm0ssXXX>>

<$button set="!!created" setTo=<<now-timestamp>>>
    Created Now
</$button>

This will set the created field to NaNNaNNaNNaNNaNNaNNaN, which is probably not what you wanted! (NaN stands for not a number, and often occurs when computers try to do math on invalid operands.) The problem is that the contents of the now-timestamp macro are not wikified in this context since the macro call is being used as an attribute of an HTML element, so TiddlyWiki tries to set the field to the literal body of the macro, which results in a bunch of NaNs when TiddlyWiki then tries to convert it to a date.

In this case, the easiest fix is not to use the now-timestamp macro, since its replacement is simple and unlikely to change anyway. But if you do want to use it, you can use a $wikify widget:

<$wikify name="currentTime" text=<<now-timestamp>>>
    <$button set="!!created" setTo=<<currentTime>>>
        Created Now
    </$button>
</$wikify>
Go to question: Ex:CreatedNowButton