How do I type perennial dates in Spanish?
Format your date in spanish With ColdFusion!
The following custom tag will allow you to display your dates in spanish, let me show you how the tag itself works:
<!--- All you have to do is call the function as
<cf_dateformates date = (a ODBC date) format = "(the format you want it to print out)"
formats:
yyyy eq. 2004
yy eq. 04
y eq. 4
mmmm eq. Enero
mmm eq. Ene
mm eq. 01
m eq. 1
dddd eq. Lunes
ddd eq. Lun
dd eq. 01
d eq. 1
Date:
Make sure that it is a ODBC date, to make it a odbcdate you can apply the following.
createODBCdate(createdate(year,month,day))
or for the server current date you can do
createODBCdate(now())
good luck and enjoy translating your date to spanish.
--->
<cfif Not IsDefined("Attributes.Date") and Not IsDefined("Attributes.Format")>
<font color="#FF0000" size="4" face="Verdana, Arial, Helvetica, sans-serif">
You have to specify a date.</font>
<cfabort>
</cfif>
<!--- first define the months in spanish --->
<cfif dateformat(Attributes.Date, 'mmmm') EQ 'January'>
<cfset month = "Enero">
<cfelseif dateformat(Attributes.Date, 'mmmm') EQ 'February'>
<cfset month = "Febrero">
<cfelseif dateformat(Attributes.Date, 'mmmm') EQ 'March'>
<cfset month = "Marzo">
<cfelseif dateformat(Attributes.Date, 'mmmm') EQ 'April'>
<cfset month = "Abril">
<cfelseif dateformat(Attributes.Date, 'mmmm') EQ 'May'>
<cfset month = "Mayo">
<cfelseif dateformat(Attributes.Date, 'mmmm') EQ 'June'>
<cfset month = "Junio">
<cfelseif dateformat(Attributes.Date, 'mmmm') EQ 'July'>
<cfset month = "Julio">
<cfelseif dateformat(Attributes.Date, 'mmmm'') EQ 'August'>
<cfset month = "Agosto">
<cfelseif dateformat(Attributes.Date,'mmmm') EQ 'September'>
<cfset month = "Septiembre">
<cfelseif dateformat(Attributes.Date, 'mmmm') EQ 'October'>
<cfset month = "Octubre">
<cfelseif dateformat(Attributes.Date,'mmmm') EQ 'November'>
<cfset month = "Noviembre">
<cfelseif dateformat(Attributes.Date, 'mmmm') EQ 'December'>
<cfset month = "Diciembre">
</cfif>
<!--- Now define the days in spanish --->
<cfif dateformat(Attributes.Date, 'dddd') EQ 'Monday'>
<cfset day = "Lunes">
<cfelseif dateformat(Attributes.Date, 'dddd') EQ 'Tuesday'>
<cfset day = "Martes">
<cfelseif dateformat(Attributes.Date, 'dddd') EQ 'Wednesday'>
<cfset day = "Miércoles">
<cfelseif dateformat(Attributes.Date, 'dddd') EQ 'Thursday'>
<cfset day = "Jueves">
<cfelseif dateformat(Attributes.Date, 'dddd') EQ 'Friday'>
<cfset day = "Viernes">
<cfelseif dateformat(Attributes.Date, 'dddd') EQ 'Saturday'>
<cfset day = "Sabado">
<cfelseif dateformat(Attributes.Date, 'dddd') EQ 'Sunday'>
<cfset day = "Domingo">
</cfif>
<!--- now process the actual tag to return values, First do the months values --->
<cfif find("mmmm","#attributes.format#")>
<cfset attributes.format = replace(attributes.format,'mmmm','#month#')>
<cfelseif find("mmm","#attributes.format#")>
<cfset attributes.format = replace(attributes.format,'mmm','#left("#month#", 3)#')>
<cfelseif find("mm","#attributes.format#")>
<cfset attributes.format = replace(attributes.format,'mm','#dateformat(Attributes.Date, 'mm')#')>
<cfelseif find("m","#attributes.format#")>
<cfset attributes.format = replace(attributes.format,'m','#dateformat(Attributes.Date, 'm')#')>
</cfif>
<!--- Next, do the days values --->
<cfif find("dddd","#attributes.format#")>
<cfset attributes.format = replace(attributes.format,'dddd','#day#')>
<cfelseif find("ddd","#attributes.format#")>
<cfset attributes.format = replace(attributes.format,'ddd','#left("#month#",3)#')>
<cfelseif find("dd","#attributes.format#")>
<cfset attributes.format = replace(attributes.format,'dd','#dateformat(Attributes.Date, 'dd')#')>
<cfelseif find("d","#attributes.format#")>
<cfset attributes.format = replace(attributes.format,'d','#dateformat(Attributes.Date, 'd')#')>
</cfif>
<cfif find("yyyy","#attributes.format#")>
<cfset attributes.format = replace(attributes.format,'yyyy','#dateformat(Attributes.Date, 'yyyy')#')>
</cfif>
<!--- Next, do the years values --->
<cfif find("yy","#attributes.format#")>
<cfset attributes.format = replace(attributes.format,'yy','#dateformat(Attributes.Date, 'yy')#')>
</cfif>
<cfif find("y","#attributes.format#")>
<cfset attributes.format = replace(attributes.format,'y','#dateformat(Attributes.Date, 'y')#')>
</cfif>
<!--- now, let's pass the value on the page, for the visitor to see --->
<cfoutput>#attributes.format#</cfoutput>
That's it, you can now have your dates displayed in spanish!
How do I type perennial dates in Spanish?
How do I get it to show up on a page... do I put the code above in the custom tag folder and call it using