Copy link to clipboard
Copied
Problem Description: DateFormat is returning a 9 character date instead of an 8 character one.
Steps to Reproduce:
1. Add the following to any Cold Fusion page:
<cfset testDate = DateFormat(Now(),"YYYYMMDD")>
<cfoutput>
Current Now(): #Now()#<br>
Test DateFormat: [#testDate#] (Length: #Len(testDate)#)<br>
</cfoutput>
Actual Result:
Current Now(): {ts '2025-07-08 13:57:51'}
Test DateFormat: [202507189] (Length: 9)
Expected Result:
Current Now(): {ts '2025-07-08 13:57:51'}
Test DateFormat: [20250708] (Length: 8)
Any Workarounds: I checked my system clock and it is indeed set to 7/8/2025 (today) so I know it's not the system clock. I also updated Cold Fusion 2023 to the latest update(15) and restarted the server but it didn't help, I still get the same error.
Browser Info: Chrome
-----------------
System Information
------------------
Time of this report: 7/8/2025, 14:04:50
Machine name: ITJN-JHTSY84
Machine Id: {921ECBB9-6C70-4E25-A872-0A8995BFE289}
Operating System: Windows 10 Enterprise 64-bit (10.0, Build 19045) (19041.vb_release.191206-1406)
Language: English (Regional Setting: English)
System Manufacturer: Dell Inc.
System Model: Precision 5860 Tower
BIOS: 2.10.0 (type: UEFI)
Processor: Intel(R) Xeon(R) w3-2423 (12 CPUs), ~2.1GHz
Memory: 65536MB RAM
Available OS Memory: 64768MB RAM
Page File: 25886MB used, 48097MB available
Windows Dir: C:\windows
DirectX Version: DirectX 12
DX Setup Parameters: Not found
User DPI Setting: 96 DPI (100 percent)
System DPI Setting: 96 DPI (100 percent)
DWM DPI Scaling: Disabled
Miracast: Available, no HDCP
Microsoft Graphics Hybrid: Not Supported
DirectX Database Version: 1.0.8
DxDiag Version: 10.00.19041.5794 64bit Unicode
2023,0,15,330825
Copy link to clipboard
Copied
This is not a bug, to be clear: it's a change of behavior that was introduced in cf2021. Those 3 digits for the day portion are because it represents the DAY OF THE YEAR, while you were expecting it to be the day of the MONTH.
And it's caused because you are using CAPITAL letters, specifically the DD. That's what changed with cf2021: it regards D to mean day of year, where forever it meant day of month, whether d or D.
So you have two options: the simplest would be to change your dateFormat to use yymmdd. But if you have many occurrences and in many files, that may seem unappealing.
The other option is to use a new jvm arg, set in the cf admin or the jvm.config file underlying cf (either of which must be done very carefully).
Both options above are covered in the cfml reference on dateFormat, as well as a technote. And I'd covered it before that in more detail when this all first was discovered in Nov 2020, when CF2021 had come out, with the first post being here. I also point out regex strings shared by folks to help find all the code using various editors, if that may interest you as another alternative.
Hope all that's helpful m
Find more inspiration, events, and resources on the new Adobe Community
Explore Now