Whatever message this page gives is out now! Go check it out!
dateTimeFormat (date)
dateTimeFormat (date [, mask])
dateTimeFormat (date [, mask, timeZone])Parameter | Description |
date | Required. A date/time object, in the range 100 AD-9999 AD. |
mask | Optional. Characters that show how ColdFusion displays a date:
Note: Unlike most other date/time mask characters, l does not simply add leading zeros as you repeat the letter for the same conceptual unit — l, ll, and lll are three separate width specifiers. If you want milliseconds displayed with guaranteed zero-padding to 3 digits (e.g., 006 instead of 6), use lll: writeOutput(dateTimeFormat(myDate, "ss.lll")); // e.g. 58.006 Using l or ll alone can produce misleadingly short output when the millisecond value is small (e.g., 58.6 instead of 58.006). Alternatively, you can pad the value manually with numberFormat(): writeOutput(dateTimeFormat(myDate, "ss.") & numberFormat(millisecond(myDate), "000")); // 58.006 The following masks tell how to format the full date and time and cannot be combined with other masks:
The function also follows Java date time mask, except for mask a. For more information, refer to Date and Time Patterns topic in SimpleDateFormat Java API page. JDK7 and JDK8 introduces the masks w, ww , W, and WW. |
timeZone | The time-zone information. You can specify in either of the following formats:
|
<cfscript>
Date1 = "{ts '2018-11-05 12:13:50'}";
DateTimeFormat= DateTimeFormat(Date1,"m")
DateTimeFormat1= DateTimeFormat(Date1,"mm")
DateTimeFormat2= DateTimeFormat(Date1,"mmm")
DateTimeFormat3= DateTimeFormat(Date1,"mmmm")
DateTimeFormat4= DateTimeFormat(Date1,"M")
writeOutput("Month as digits; no leading zero for single-digit months: " & DateTimeFormat & "<br/>")
writeOutput("Month as digits; leading zero for single-digit months: " & DateTimeFormat1 & "<br/>")
writeOutput(" Month as a three-letter abbreviation.: " & DateTimeFormat2 & "<br/>")
writeOutput(" Month as a three-letter abbreviation.: " & DateTimeFormat3 & "<br/>")
writeOutput(" Month in year: " & DateTimeFormat4 & "<br/>")
</cfscript>