spanish output for "date" function

645 views Asked by At

i want to echo cMonth in spanish.. i was trying differents things without result. any idea?

if($_REQUEST["month"]>0){
    $cMonth = "0".intval($_REQUEST["month"]);
    if ($_REQUEST["month"]>9) {
        $cMonth = intval($_REQUEST["month"]);
    }
    $cYear = intval($_REQUEST["year"]);
}else
{
    $cMonth = date("m");
    $cYear = date("Y");
}

echo date("F, Y",strtotime($cYear."-".$cMonth."-01")); 
1

There are 1 answers

5
Barkati.med On

Hi You can use this methode Just

    setlocale(LC_ALL, "es_ES", 'Spanish_Spain', 'Spanish');
    $string = "27/12/2016";
    $date = \DateTime::createFromFormat("d/m/Y", $string);
    echo strftime("%B", $date->getTimestamp());