ColdFusion Zeus POTW - Extra edition...

Ok, I know I did a Zeus POTW earlier this week, but I had to share this little gem. This is another small thing - a simple function - and something that’s been possible via a CFLib UDF for years. That being said - when I saw this show up in the latest Zeus build today, I had to share.

If you’ve ever needed to format a date and a time, you know that it requires two calls, ala:

<cfoutput> #dateFormat(now())# #timeFormat(now())# </cfoutput>

Zeus adds dateTimeFormat to combine this into one call:

<cfoutput> #dateTimeFormat(now())#<br/> </cfoutput>

For formatting, the mask is slightly different than before. Masks are based on SimpleDateFormat from Java. So for example:

<cfoutput> #dateTimeFormat(now(), "MMMM d, yyyy h:mm a")#<br/> </cfoutput>

Yeah, ok, not Earth-shattering, but this was one of a few new functions released in the latest Zeus build that were things I’ve seen requested for years.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Comments