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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

spanish date script

Status
Not open for further replies.

StephanieCC

Technical User
Aug 28, 2001
48
US
I have a date script on my site and have just created a Spanish version of the site and have been looking for a way to have the date display in Spanish--here's the script:

<script language="JavaScript"><!--
var thisyear = today.getYear(); // varies in JavaScript and JScript
document.write(isnMonths[today.getMonth()+1]+" "+today.getDate()+", ")
if (thisyear >= 2000) { // covers JScript post 2000
document.write(thisyear);
}
else { // covers JScript from 1900 thru 1999 and JavaScript until 3899
document.write(1900 + thisyear);
} // not handled: JScript pre 1900
-->
</script>

here's the English web page with date

here's the Spanish page

thanks, Stephanie
 
I don't program Javascript so can't help with the syntax.
You already have the day number and month number so set up arrays DaysOfWeek and MonthsOfYear and create the display on the fly.

Keith
 
Just as a side note, you should use today.getFullYear() if you want the year in 4 digits.
Also, I don't even think you need to specifically check that the year is less than or greater than 2000 unless you simply want to send an alert to the user to fix their time/date settings.
Lastly, if you're trying to do a list of Spanish months, set them up in an array.
var spanishMonths=new Array("enero","febrero",...etc.)

Then you could do...
var date=spanishMonths[today.getMonth()]+" "+today.getDate()+", "+today.getFullYear();

Or something like that, anyway.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top