PHP - Date Function

Asked

Viewed 28 times

0

I created this date function to show the date, day and month.

The problem is that it shows the més in English..

exemplo: March, 10, 2018".

How do I make him read in Portuguese?

function dateName($date) {

    $result = "";

    $convert_date = strtotime($date);
    $month = date('F',$convert_date);
    $year = date('Y',$convert_date);
    $name_day = date('l',$convert_date);
    $day = date('j',$convert_date);


    $result = $month . " " . $day . ", " . $year;

    return $result;
}
  • Just to contribute a little bit, research on Carbon, it solves this very well. I’m not saying USE, I’m saying to know the tool and suddenly pick up ideas by reading the source code.

  • Sometimes I don’t understand, whether this is to help or just another unanswered Forum.

  • Your answer is here https://answall.com/questions/8317/como-fazer-a-fun%C3%A7%C3%A3o-date-formatar-uma-data-em-portugu%C3%Aas

  • I might have been there, but since I put that in the code.....

  • Try to insert this at the beginning of your function: setlocale(LC_TIME, 'pt_BR', 'pt_BR.utf-8', 'pt_BR.utf-8', 'portuguese');
date_default_timezone_set('America/Sao_Paulo');

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.