English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Manuale delle funzioni di data/ora di PHP
La funzione getdate() di PHP ottiene informazioni sulla data/ora
La funzione getdate() di PHP viene utilizzata per ottenere informazioni sulla data/ora specificata. Accetta un parametro opzionale per specificare il timestamp per cui si desiderano informazioni. Se non viene passato alcun parametro, questa funzione restituisce informazioni sulla data/ora locale corrente.
getdate([$timestamp])
Numero di serie | Parametri e descrizione |
---|---|
1 | timestamp Opzionale) Questo rappresenta l'etichetta del timestamp della data/ora specificata. |
La funzione getdate() di PHP restituisce un array che contiene informazioni sulla data/ora specificata. Le unità di chiave dell'array associativo restituito includono:
Key name | Description | Return value example |
---|---|---|
"seconds" | numeric representation of the second | 0 to 59 |
"minutes" | numeric representation of the minute | 0 to 59 |
"hours" | numeric representation of the hour | 0 to 23 |
"mday" | numeric representation of the day of the month | 1 to 31 |
"wday" | numeric representation of the day of the week | 0 (Sunday) to 6 (Saturday) |
"mon" | numeric representation of the month | 1 to 12 |
"year" | 4-digit number representing the full year | such as: 1999 or 2003 |
"yday" | numeric representation of the day of the year | 0 to 365 |
"weekday" | full text representation of the day of the week | Sunday to Saturday |
"month" | full text representation of the month, such as January or March | January to December |
0 | the number of seconds since the Unix epoch to the present day, and time() return value and for date() value is similar. | System related, typical value is from -2147483648 to 2147483647. |
This function was initially introduced in PHP version 4 and can be used in all higher versions.
The following examples demonstrategetdate()Usage of the function-
<?php $info = getdate(); print_r($info); ?>Test to see‹/›
Output result
Array ( [seconds] => 34 [minutes] => 52 [hours] => 12 [mday] => 8 [wday] => 5 [mon] => 5 [year] => 2020 [yday] => 128 [weekday] => Friday [month] => May [0] => 1588942354 )
Now, let's try to pass the timestamp to this function-
<?php $timestamp = time()-(23*12*30); $info = getdate($timestamp); print_r($info); ?>Test to see‹/›
Output result
Array ( [seconds] => 29 [minutes] => 49 [hours] => 10 [mday] => 8 [wday] => 5 [mon] => 5 [year] => 2020 [yday] => 128 [weekday] => Friday [month] => May [0] => 1588934969 )