Function date returning month in en

Asked

Viewed 2,830 times

1

Has some form of function date return the current month in en?

Example: ["Jan", "Feb", "Mar", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]

1 answer

3


example - ideone

strftime - Formats a time/date according to local settings

%b brings the abbreviated month https://secure.php.net/manual/en/function.strftime.php

setlocale(LC_ALL, 'pt_BR', 'pt_BR.utf-8', 'pt_BR.utf-8', 'portuguese');
date_default_timezone_set('America/Sao_Paulo');
echo strftime('%b', strtotime('today'));

If you just want to set the dates just change LC_ALL for LC_TIME

The function setlocale is responsible for specifying the type of locality desired to perform operations of a category. The first parameter represents the category of operations, and must be one of the following constants:

LC_COLLATE - para especificar as regras da localidade para comparação de textos.
LC_CTYPE - para especificar as regras da localidade para classificação/conversão de caracteres.
LC_MONETARY - para especificar a notação monetária de uma localidade.
LC_NUMERIC - para especificar a notação numérica de uma localidade.
LC_TIME - para especificar a notação de data/tempo de uma localidade.
LC_MESSAGES - para especificar o idioma das mensagens de log.
LC_ALL - para especificar a localidade para todas as categorias.

The second parameter must be a string, with the name of the locale according to the operating system. This is because the setlocale function uses the locale settings defined on the server, including its name.

For example, in Linux, we can install the locale definitions for Brazilian Portuguese and modify the locale rules with the string "pt_BR", while in Windows, the string can be "Portuguese_brazil". The charset is also important, since some operations depend on it.

We can pass a third, fourth, fifth parameter, etc. to the setlocale function, specifying several possible localities. The first one to be found by the server is used. See the example:

setlocale(LC_ALL, 'pt_BR.UTF-8', 'Portuguese_Brazil.1252');
  • Thank you very much.

Browser other questions tagged

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