Not yet rated

Problem

While formatting dates with DateFormat function, output is only available.

Solution

We can use available LSDateFormat function with an activated locale to render dates in required locale format.

Detailed explanation

Here is the code sample:

<cfscript>
    /*
        Setting required locale
        tr_TR used for Turkish
    */
    SetLocale("tr_TR");
   
       /* Defining custom parameters */
    myTime = Now();
    myDateFormat = "DD MMMM YYYY, DDDD";   
</cfscript>

<!--- Formatting output --->
<cfoutput>
    #LSDateFormat(myTime,myDateFormat)#
</cfoutput>
<br />
<br />
<!--- Formatting output for available locales in ColdFusion --->
<cfoutput>
<cfloop index="loopid" list="#server.coldfusion.supportedlocales#">
    <cfscript>SetLocale("#loopid#");</cfscript>
    #loopid#: #LSDateFormat(myTime,myDateFormat)#<br />
</cfloop>
</cfoutput>


+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes