Edit date with edit-text and format output

Hello,

I want edit date with specific format like

	<$edit-text
		field="h_date_start"
		tag="input"
		type="datetime-local"
	/>

actualy h_date_start:2024-10-18T17:21
but I want default tiddlywiki format like: 202410181721

How can I do that ?

Regards,

You can use two fields plus an inputActions parameter, like this:

\define convertDate()
<$let pat="[-T:]">
<$action-setfield h_date_start={{{ [<actionValue>search-replace:g:regexp<pat>,[]] }}}/>
\end

<$edit-text field="h_date_start_input"
   tag="input" type="datetime-local" inputActions="<<convertDate>>"/>

INPUT={{!!h_date_start_input}}<br>
VAL={{!!h_date_start}}

Notes:

  • The h_date_start_input field holds the input from the $edit-text widget
  • The h_date_start field holds the input value converted to the desired format
  • inputActions=... invokes <<convertDate>> on each keystroke, and takes the current input (in the actionValue variable), strips out the '-, ‘T’, and ‘:’ characters, and saves it input the h_date_start target field

-e

Thanks a lot, tiddlywiki is powerfull but a little hard :wink: