Dumped in Coldfusion

Monday, February 13, 2006

Displaying DateTimes in Coldfusion

It seems that there is no way of formatting a date with a time in Coldfusion. Yes, you can format a date, and yes, you can format a time, but the combination appears to be lacking.

You get most of the way there with something like

#DateFormat(date, "dd mmm yyyy HH:mm:ss")#

However you may after a while notice that all of the times have the same number of minutes. Astute readers will have noticed that "mm" means "2 digit month number", not "2 digit minutes". Now the documentation implies that HH and ss should have just shown up as the letters, not as the representations of the time part of the DateTime.

Obviously what you have to do is

#DateFormat(date, "dd mm yyyy")# #TimeFormat(date, "HH:mm:ss")#

Surely there should be a way of doing this as one command. Why are they different methods anyway? Most languages manage to formate date-times with the same functions.

0 Comments:

Post a Comment

<< Home