Saltar para o conteúdo principal
Versão: 20 R6 BETA

Formatos data e hora

Throughout your 4D projects, you might need to format date and/or time values according to the specificities of the application, the platform, or the interface.

4D includes a comprehensive list of patterns that you can use to create and apply customized date and time formats in your applications, in addition to default formats. Customized format patterns are supported by the following features:

Lista de padrões

The following table lists all supported patterns for date and time formats.

SímboloSignificadoPadrãoExemplo de saída
Gdesignador de eraG, GGG ou GGGAD
GGGGAnno Domini
GGGGGA
yanoyy96
y ou yyyy1996
Yano da "Semana do ano"Y1997
uano prolongadou4601
QtrimestreQ2
QQ02
QQQQ2
QQQQ2º trimestre
QQQQQ2
qtrimestre autônomoq2
qq02
qqqQ2
qqqq2º trimestre
qqqqq2
Mmês no anoM9
MM09
MMMSet
MMMMSetembro
MMMMMS
Lmês autônomo no anoL9
LL09
LLLSet
LLLLSetembro
LLLLLS
wsemana do anow27
ww27
ddia no mêsd2
dd2
Ddia do anoD189
Edia da semanaE, EE ou EEETue
EEEETuesday
EEEEET
EEEEEETu
edia da semana locale2
ee02
eeeTue
eeeeTuesday
eeeeeT
eeeeeeTu
cstand-alone local day of weekc ou cc2
cccTue
ccccTuesday
cccccT
ccccccTu
aAM ou PMa, aa, ou aaaPM [abbrev]
aaaaPM [wide]
aaaaap
bAM, PM, meio-dia, meia-noiteb, bb ou bbbmid.
bbbbmeia-noite
bbbbbmd
Bflexible day periodsB, BB ou BBBat night [abbrev]
BBBBat night [wide]
BBBBBat night [narrow]
hhora em am/pm (1~12)h7
hh07
Hhora no dia (0~23)H0
HH00
Khora em am/pm (0~11)K0
KK00
khora no dia (1~24)k24
kk24
mminuto em horam4
mm04
ssegundo em minutos5
ss05
XTime Zone: ISO8601 basic hm?, with Z for 0X-08, +0530, Z
Zona de tempo: ISO8601 hm, com ZXX-0800, Z
Time Zone: ISO8601 extended hm, with ZXXX-08:00, Z
Time Zone: ISO8601 basic hms?, with ZXXXX-0800, -075258, Z
Time Zone: ISO8601 extended hms?, with ZXXXXX-08:00, -07:52:58, Z
xTime Zone: ISO8601 basic hm?, without Z for 0x-08, +0530
Time Zone: ISO8601 basic hm, without Zxx-800
Time Zone: ISO8601 extended hm, without Zxxx-08:00
Time Zone: ISO8601 basic hms?, without Zxxxx-0800, -075258
Time Zone: ISO8601 extended hms?, without Zxxxxx-08:00, -07:52:58
OFuso horário: GMT localizado curtoOGMT-8
Time Zone: long localized GMT (=ZZZZ)OOOOGMT-08:00
zTime Zone: specific non-locationz, zz ou zzz-0800
zzzzGMT-08:00
zzzzz-08:00, -07:52:58, Z
'escape for text''
' 'duas aspas simples produzem uma' '' '

Explorando padrões

y vs Y

y es el año calendario, mientras que Y es el año basado en el número de semana. For example, if the first days of January 2010 are not week #1, then y = 2010 but Y = 2009 (until the date where the 1st week of 2010 begins).

L (monopuesto) vs M

In some languages (Russian, Slovak), the month used alone is different from the month in a date. In "January 10, 2010", "January" is not spelled the same as in "rendez-vous in January".

e vs c

Same remark as for L and M: c is for a day used alone "every tuesday") and e is for a day in a date ("Tuesday January 15, 1951").

E vs e

e se basa en la configuración del sistema: si la semana está definida en el sistema como que comienza un miércoles, entonces el miércoles tendrá el valor numérico "1" (o cero) mientras que "E" siempre devuelve el mismo valor (de 1 a 7 o de 0 a 6).

Zeros à esquerda

In general, when the number of letters in the formatting string is higher than the expected number, leading zeros are added. Ex: "yyyyyy" daria "001996".

Peças localizadas

Some parts of the outputs, such as "midnight" or "Tuesday" are localized, according to regional settings.

Por ejemplo, para la hora 13:25:34, "B" aparecerá in the afternoon en un sistema estadounidense, y après-midi en un sistema francés.

Letras extras

Formatting strings can contain characters not to be interpreted as formatting characters: if they are between "a" and "z" or "A" and "Z", they must be enclosed in single quotes.

Por exemplo:

"15:30:00" with pattern "HH 'hours and' mm 'minutes'" produces "15 hours and 30 minutes".

Espaços iniciais e finais

Starting and ending spaces in patterns are automatically trimmed in outputs. If you want to add spaces before or after the resulting string, you must enclose them in single quotes.

Por exemplo:

" HH : mm : ss " ---> "09 : 10 : 25" "' 'HH : mm : ss' '" ---> " 09 : 10 : 25 "

Exemplos

Data ou horaPadrãoResultadosComentários
15/06/2000"QQQQ""2º trimestre"localizado
17/03/2001"D""76"76º dia do ano
17/03/1954"w""11"11ª semana do ano
17/03/1954"eeee""Quarta-feira"localizado
15:00:00"a""PM"
18:00:00"K a""6 PM"
13:30:15"hh:mm aa O""01:30 PM GMT+1"

Veja também

Ver este blogpost para más información sobre los formatos personalizados de fecha y hora.