GetLocale()
Gets the current geographic/language locale value.
To set the default display format of date, time, number, and currency values in a CFML application session, you use the SetLocale() function.
GetLocale( );
Returns: String
This function does not take any arguments.
Examples
var n = 1234.56;
writeOutput( getlocale() );
dump( dateTimeFormat( now() ) );
dump( LSdateTimeFormat( now() ) );
dump( numberFormat( n ) );
dump( LSnumberFormat( n ));
<span class="nf">writeOutput</span><span class="p">(</span><span class="s1">' To '</span><span class="p">);</span>
<span class="nf">setLocale</span><span class="p">(</span> <span class="s1">'french(switzerland)'</span> <span class="p">);</span>
<span class="nf">writeOutput</span><span class="p">(</span> <span class="nf">getlocale</span><span class="p">()</span> <span class="p">);</span>
<span class="nf">dump</span><span class="p">(</span> <span class="nf">dateTimeFormat</span><span class="p">(</span> <span class="nf">now</span><span class="p">()</span> <span class="p">)</span> <span class="p">);</span>
<span class="nf">dump</span><span class="p">(</span> <span class="nf">LSdateTimeFormat</span><span class="p">(</span> <span class="nf">now</span><span class="p">()</span> <span class="p">)</span> <span class="p">);</span>
<span class="nf">dump</span><span class="p">(</span> <span class="nf">numberFormat</span><span class="p">(</span> <span class="nv">n</span> <span class="p">)</span> <span class="p">);</span>
<span class="nf">dump</span><span class="p">(</span> <span class="nf">LSnumberFormat</span><span class="p">(</span> <span class="nv">n</span> <span class="p">)</span> <span class="p">);</span>
<span class="nf">writeOutput</span><span class="p">(</span><span class="s1">' To '</span><span class="p">);</span>
<span class="nf">setLocale</span><span class="p">(</span> <span class="s1">'German'</span> <span class="p">);</span>
<span class="nf">writeOutput</span><span class="p">(</span> <span class="nf">getlocale</span><span class="p">()</span> <span class="p">);</span>
<span class="nf">dump</span><span class="p">(</span> <span class="nf">dateTimeFormat</span><span class="p">(</span> <span class="nf">now</span><span class="p">()</span> <span class="p">)</span> <span class="p">);</span>
<span class="nf">dump</span><span class="p">(</span> <span class="nf">LSdateTimeFormat</span><span class="p">(</span> <span class="nf">now</span><span class="p">()</span> <span class="p">)</span> <span class="p">);</span>
<span class="nf">dump</span><span class="p">(</span> <span class="nf">numberFormat</span><span class="p">(</span> <span class="nv">n</span> <span class="p">)</span> <span class="p">);</span>
<span class="nf">dump</span><span class="p">(</span> <span class="nf">LSnumberFormat</span><span class="p">(</span> <span class="nv">n</span> <span class="p">)</span> <span class="p">);</span>
See also
- Date and time
- Internationalization
- GetLocaleInfo()
- SetLocale()
- Locale
- Search Issue Tracker
- Search Lucee Test Cases (good for further, detailed examples)