2014-06-27, 16:07:32
I have improved the function to translate "String" date to "number" date.
Now, you can use easily any languaje you need:
Now, you can use easily any languaje you need:
PHP Code:
// this is a function to translate spanish dates like "enero 2014" to numbers like "1/01/2014"
function date_es_to_en($date_es ) {
$fecha = explode(" ", $date_es);
$anno = $fecha[1];
$es = array("enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre");
$en = array("january", "februrary", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december");
// add here a new languaje array if you need...
$numbers = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12");
// this replace all month names with his number for each languaje:
$translated_month = str_replace($en, $numbers, $fecha[0]);
$translated_month = str_replace($es, $numbers, $fecha[0]);
// add here a new languaje str_replace if you need...
$date_en = $translated_month."/1/".$anno;
return $date_en;
}