Pete Freitag Pete Freitag

DateFormat, and TimeFormat mask shortcuts

Published on August 09, 2005
By Pete Freitag
coldfusion

Did you know that there were some date/time mask shortcuts for the DateFormat, and TimeFormat functions? They were added in ColdFusion MX 6.0, and they flew under the radar for many. I have seen them in the docs when I lookup a mask, but I always forget about them. The masks are short, medium, large, and full.

For Example:

short: #DateFormat(Now(), "short")# #TimeFormat(Now(), "short")#
medium: #DateFormat(Now(), "medium")# #TimeFormat(Now(), "medium")#
long: #DateFormat(Now(), "long")# #TimeFormat(Now(), "long")#
full: #DateFormat(Now(), "full")# #TimeFormat(Now(), "full")#

Will output:

short: 8/9/05 3:09 PM
medium: Aug 9, 2005 3:09:50 PM
long: August 9, 2005 3:09:50 PM EDT
full: Tuesday, August 9, 2005 3:09:50 PM EDT

PS - I have added a DateFormat CheatSheet to my collection of Cheet Sheets.



cfml dateformat timeformat tips

DateFormat, and TimeFormat mask shortcuts was first published on August 09, 2005.

If you like reading about cfml, dateformat, timeformat, or tips then you might also like:

Fixinator

The Fixinator Code Security Scanner for ColdFusion & CFML is an easy to use security tool that every CF developer can use. It can also easily integrate into CI for automatic scanning on every commit.


Try Fixinator

CFBreak
The weekly newsletter for the CFML Community


Comments

i use these religously. trying to parse a custom localized datestring back to a datetime object would often be impossible otherwise.
by PaulH on 08/09/2005 at 4:21:17 PM UTC
niiiiiiiiice... just learned something new today, and i just got to work :)
by forgetfoo on 08/10/2005 at 8:35:21 AM UTC