portal entry

select a category, or use search below
(searches all categories and all time range)
Title:

Quick tip: escaping string literals in dateTimeFormat()

| View in Portal
December 09, 2018 05:45:09 AM GMT
4 Comments
<p>Just a quick tip since I didn’t find this to be well documented anywhere and someone else probably has this exact same problem.  Frequently, I display time and date on a page.  I used to do it like so: #dateFormat(now(),'dddd, mmmm d, yyyy')# at #timeFormat(now(),'h:mm tt')# …but why use two functions when you can use one, right?  So I tried using the following: #dateTimeFormat(now(),'dddd, mmmm d, yyyy at h:mm tt')# But got briefly stuck when the ‘t’ in the date […]</p>
<p>The post <a rel="nofollow" href="https://coldfusion.adobe.com/2018/12/quick-tip-escaping-string-literals-in-datetimeformat/">Quick tip: escaping string literals in dateTimeFormat()</a> appeared first on <a rel="nofollow" href="https://coldfusion.adobe.com">ColdFusion</a>.</p>
Labels: Blog, CFML Tag/Function, Language Enhancements, Showcase, cfml tag/function, ColdFusion, language enhancements, showcase

Comments:

I hope Adobe adds this to their documentation. Can you add a link to a live version.
Comment by James Mohler
1489 | December 10, 2018 04:26:53 PM GMT
This also works (single quotes around the date arguments, double single quotes around AT): #dateTimeFormat(now(),'dddd, mmmm d, yyyy ''at'' h:mm tt')#
Comment by Mark Gregory
1492 | December 10, 2018 06:02:28 PM GMT
Mark;  This does <em>not</em> work under ACF at least. <a href="https://cffiddle.org/app/file?filepath=6022bf1a-4040-403b-ba8c-92c7e17fac8a/b33ba0e5-6a0e-46ee-b83e-4d95012a6a57/ae632e76-e3a3-44b4-bac8-4e7fcf40e4ca.cfm" rel="nofollow">CFFiddle example</a>
Comment by David Byers
1495 | December 10, 2018 08:20:26 PM GMT
Hi David, Nice find! Filed <a href="https://tracker.adobe.com/#/view/CF-4203797" rel="nofollow">https://tracker.adobe.com/#/view/CF-4203797</a> giving you credit. Thanks!, -Aaron
Comment by Aaron Neff
1506 | December 18, 2018 04:34:56 AM GMT