Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

French Date

Status
Not open for further replies.

izachar

Technical User
Oct 7, 2000
84
CA
I am built a site that is in English and now I have to make it available in French. I am having problems with the date format. The first letter is capitalized and it should not and some of the months are spelled in English not french. Is there a system varable for it or will I have to hardcode a drop-down in French and pull it out of the DB ?
 
try to use GetTimeZoneInfo() function; here is the example:

<CFOUTPUT>
The local date and time are #now()#.
</CFOUTPUT>

<CFSET info = GetTimeZoneInfo()>
<CFOUTPUT>
<P>Total offset in seconds is #info.utcTotalOffset#.</P>
<P>Offset in hours is #info.utcHourOffset#.</P>
<P>Offset in minutes minus the offset in hours is #info.utcMinuteOffset#.</P>
<P>Is Daylight Savings Time in effect? #info.isDSTOn#.</P>
</CFOUTPUT>

the info.utcHourOffset is returning the offset in hours of local time from Universal Coordinated Time (UTC); with that you can position the country in that span; I don't know what would be for France, but for example, I am in Seattle and Offset in hours here is 8; therefore, France might be 0 (which is same time zone as London);

now, with that you can use something like this to format you date:

<cfif info.utcHourOffset is 0> <!---or whatever is the value for France--->
<cfset date = DateFormat(now(), &quot;d mmmm yy&quot;)>
<cfset date = ListSetAt(date, 2, LCase(LisTGetAt(date, 2, &quot; &quot;)), &quot; &quot;)>
</cfif>


the new date output: 7 november 01


hope this help :)

Sylvano
dsylvano@hotmail.com
 
Thank you for the responce. I my problem is that in french May is Mai so when I use mmm in my date format it does not spell correctly. Also when I display full month then I have aproblem that in French month/day/year is day month (with no capital letter in front) year. As much as I know I can not force a month variable to not capitalize in the front.
 
the code i have offered you here will determine if the France date format is needed to be displayed;
now you are asking that instead month/day/year, the date be displayed as day/month/year, right?
u can accomplish that by using different mask in the DateFormat() function;
instead
<cfset date = DateFormat(now(), &quot;d mmmm yy&quot;)>
use this
<cfset date = DateFormat(now(), &quot;mmmm d yy&quot;)>

the available masks for DateFormat() function:
mask
Set of characters that are used to show how ColdFusion should display the date:

d -- Day of the month as digits with no leading zero for single-digit days.
dd -- Day of the month as digits with a leading zero for single-digit days.
ddd -- Day of the week as a three-letter abbreviation.
dddd -- Day of the week as its full name.
m -- Month as digits with no leading zero for single-digit months.
mm -- Month as digits with a leading zero for single-digit months.
mmm -- Month as a three-letter abbreviation.
mmmm -- Month as its full name.
y -- Year as last two digits with no leading zero for years less than 10.
yy -- Year as last two digits with a leading zero for years less than 10.
yyyy -- Year represented by four digits.
gg -- Period/era string. Currently ignored, but reserved for future use.

here are few examples:
<CFSET todayDate = Now()>
<CFOUTPUT>
#DateFormat(todayDate)#<br>
#DateFormat(todayDate, &quot;mmm-dd-yyyy&quot;)#<br>
#DateFormat(todayDate, &quot;mmmm d, yyyy&quot;)#<br>
#DateFormat(todayDate, &quot;mm/dd/yyyy&quot;)#<br>
#DateFormat(todayDate, &quot;d-mmm-yyyy&quot;)#<br>
#DateFormat(todayDate, &quot;ddd, mmmm dd, yyyy&quot;)#<br>
#DateFormat(todayDate, &quot;d/m/yy&quot;)#<br>
</CFOUTPUT>


in short, the following code:
<cfset frenchMonths = &quot;janvier,f&eacute;vrier,marcher,avril,juin,juillet,ao&ucirc;t,septembre,octobre,novembre,d&eacute;cembre&quot;>

<cfset date = DateFormat(Now(), &quot;m d yy&quot;)>
<cfset fMonth = ListGetAt(frenchMonths, ListGetAt(date, 1, &quot; &quot;))>
<cfset frenchDate = ListSetAt(date, 1, fMonth, &quot; &quot;)>

<cfoutput>#frenchDate#</cfoutput>

will give you this output:

décembre 8 01


ColdFusion has many functions to manipulate date an strings; to use database for something like french date formating would be simply uneffective; if you need coldfusion documentation with description of all ColdFusion funtions and tags go to:

Sylvano
dsylvano@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top