Top Menu
 i got a requirment wherein i user add date in US(English) format but user want to display spanish language/or Other Language.

First Method :


/* Windows con apache
setlocale(LC_TIME, ‘Spanish’); */

/* Apache con linux */
/* setlocale(LC_TIME, ‘es_ES’); */

// setlocale(LC_TIME, ‘de_DE’); 
// echo strftime(‘%A, %d. %B %Y’);  

/* setlocale(LC_TIME, ‘es_MX’); */

setlocale(LC_TIME, ‘es_ES’); //pase language code 
echo $fecha=strftime(‘%B %d %Y’,strtotime(’01-09-2012′));// Output septiembre 01 2012

Second Method 

function converttospanish($paramdate)
{
$str=$paramdate;
$month = array(“”,”enero”, “febrero”, “marzo”, “abril”, “mayo”, “junio”, “julio”, “agosto”, “septiempre”, “diciembre”);// you can change different language 
if (($timestamp = strtotime($str)) !== false)
{
$php_date = getdate($timestamp);
$dm = date_parse_from_format(“Y-m-d”, $paramdate);
echo $php_date[“mday”].’ ‘.$month[$dm[“month”]].’ ‘.$php_date[“year”];
}
else
{
echo ‘invalid timestamp!’;
}
}


About The Author

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Close