Hi Everyone,
I have a case where I need the snippet, in this case, the date picker, to expand in all caps (i.e., OCTOBER 14, 2026). Is there a way to use a custom format to do this?
Hi Everyone,
I have a case where I need the snippet, in this case, the date picker, to expand in all caps (i.e., OCTOBER 14, 2026). Is there a way to use a custom format to do this?
You can nest the date picker within a JavaScript snippet. The JavaScript can then convert the date you’ve picked to both all caps and your desired format.
So as per the screen grab, select Content Type as JavaScript, add your date picker and name it picker. Ensure the date format you select in YYYY-MM-DD. Don’t worry, the JS will do the format conversion.
Then, after your picker, on the line below, paste in the following…
var s = (TextExpander.filledValues && TextExpander.filledValues.picker||"").trim();
var m = s.match(/^(\d{4})-(\d{2})-(\d{2})$/);
if (!m) {
'Couldn’t parse the date: "' + s + '"';
} else {
new Date(+m[1], +m[2] - 1, +m[3])
.toLocaleDateString("en-US", {
month: "long",
day: "numeric",
year: "numeric"
}).toUpperCase();
}
On expansion, you can click on the date picker, select, say today’s date, and the output will be OCTOBER 14, 2026.
Hope that helps.
This works great! Thank you, @TDK!