|
If we print with normality the date on our page, by means of PHP, of course this one will appear in English. If we put something like that:
<? php I begin strftime ("%A %d of %B of %Y");?>
There will appear for example "Thursday 17 of February of 2005", thing that will not stay much according to our page, if this one is in Spanish language.
The best solution is to form the places and PHP will do the rest for us. The places are translations of basic things, as the date, which usually come in the operating system. Let's see like forming places for the Spanish language:
set_locale (LC_ALL, "es_ES@euro", "es_ES", "esp");
We put several options if the first one is not free, it will jump to the following one and this way successively. If now we prove the same code:
<? php
set_locale (LC_ALL, "es_ES@euro", "es_ES", "esp");
I begin strftime ("%A %d of %B of %Y");
?>
It will appear "Thursday, the 17th of February 2005".
If we have not places, we can do the translation ourselves. For example, for the day of the week we would do something like that:
<? php
$dias = array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
I begin "Today it is".$dias [date ('w')];
?>
date ('w') he is sick the day of the week, between 0 and 6. 0 is Sunday and 6 on Saturday. For the month we can make something similar, knowing that I dated ('n') he is sick the month, between 1 and 12. It is necessary to bear in mind that in this case it does not start from 0.
For Alex. |