Post date of the Portuguese post using [processwire] [duplicate]

1

I'm using processwire and to put the post creation date I used the following code

<?php  echo ( date("F j, Y ", $page->created). "at " . date("g:i A", $page->created));  ?></p>

However this code does show the date in English format and I would like to translate it into Portuguese

I'll show you the change I made

<p><span class="glyphicon glyphicon-time"></span> Posted on <?php  echo ( date("F j, Y ", $page->created). "at " . date("g:i A", $page->created));  //antes
                                        //Alteração apartir daqui
                                      // strftime("%A, %d de %B de %Y", strtotime( $page->created));
                                        $en = ['','January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
                                        $pt = [' de ', 'janeiro', 'fevereiro', 'março', 'abril', 'maio', 'junho', 'julho', 'agosto', 'setembro', 'outubro', 'novembro', 'dezembro']; 
                                            echo("<br>");
                                         echo str_replace($en, $pt, strftime("%d de %B de %Y as %H:%M", strtotime($date)));
                                        ?>
</p>

What I was before September 2, 2015 at 10:31 AM

After the January 1, 1970 change at 01:00

The dates are different

If someone can add the processwire tag in stackoverflow English already exists

    
asked by anonymous 28.09.2015 / 13:22

1 answer

1

According to this discussion , you can do as follows by setting the language in your config.php:

$config->timezone = 'America/Sao_Paulo';
setlocale(LC_ALL, 'pt_BR');

And display the date as follows:

echo strftime("%A, %d de %B de %Y", strtotime( $page->created));

If you can not change the default language, you can manually translate:

    $date = '1441186272'; // $page->created

    $en = array('','January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
    $pt = array(' de ', 'janeiro', 'fevereiro', 'março', 'abril', 'maio', 'junho', 'julho', 'agosto', 'setembro', 'outubro', 'novembro', 'dezembro'); 

    echo str_replace($en, $pt, strftime("%d de %B de %Y as %H:%M", $date));

Will return:

  

September 28, 2015 at 08:54

    
28.09.2015 / 13:36