Reputation: 28483
I'm trying to use the Coldfusion DateFormat Function. Can someone tell me, why doing this:
#DateFormat( now(), "YYYY-MM-DD HH:MM:SS")#
returns this:
2012-07-17 16:07:666
Why the 666 milliseconds? something devilish???
Upvotes: 4
Views: 798
Reputation: 8314
I prefer to use the Java SimpleDateFormat where the date mask is case sensitive.
<cfscript>
createObject('java','java.text.SimpleDateFormat').init('yyyy-MM-dd HH:mm:ss.SSS').format(now());
</cfscript>
http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html
eg. 2010-07-19 11:46:12.029
Upvotes: 1
Reputation: 3884
DateFormat does not format time. Use TimeFormat for time.
Edit:
Use this code for date-time output.
#dateFormat(now(),'YYYY-MM-DD')# #timeFormat(now(), 'HH:MM:SS')#
Upvotes: 8