note 17095 added to control-structures.switch
| From: | marianocalandra at libero dot it | Date: | Mon, 26 Nov 2001 12:57:35 +0000 |
| Subject: | note 17095 added to control-structures.switch | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-21279@lists.php.net to get a copy of this message | ||
for english or american people are no problem for name of month,
but for the italian(as me) or some people that no speak english
this can be a good solution for insert the name of month.
//this is my date
$date="2001-11-26";
//extraction 3 parts of date
$year=substr($date,0,4);
$mounth0=substr($date,5,2);
$day=substr($date,8,2);
//part of switch,
//more IMPORTANT
switch($mounth0){
case 1:
$mounth="Gennaio"; //or january
break;
case 2:
$mounth="Febbraio";
break;
case 3:
$mounth="Marzo";
break;
case 4:
$mounth="Aprile";
break;
case 5:
$mounth="Maggio";
break;
case 6:
$mounth="Giugno";
break;
case 7:
$mounth="Luglio";
break;
case 8:
$mounth="Agosto";
break;
case 9:
$mounth="Settembre";
break;
case 10:
$mounth="Ottobre";
break;
case 11:
$mounth="Novembre";
break;
case 12:
$mounth="Dicembre";
break;
}
echo"$day-$mounth-$year";
in this way we have change date format and
we have get a name at the mounth with italian language.
Probably this isn't a way more fast but this is the more easy ;-)
--
http://www.php.net/manual/en/control-structures.switch.php
http://master.php.net/manage/user-notes.php?action=edit+17095
http://master.php.net/manage/user-notes.php?action=delete+17095
http://master.php.net/manage/user-notes.php?action=reject+17095