Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
timestamp.get_date
timestamp.get_date(unix_seconds [, time_zone])
Descrizione
Questa funzione restituisce una stringa nel formato YYYY-MM-DD
, che rappresenta il giorno in cui si trova un timestamp.
unix_seconds
è un numero intero che rappresenta il numero di secondi trascorsi dall'epoca Unix, ad esempio $e.metadata.event_timestamp.seconds
, o un segnaposto contenente questo valore.
time_zone
è facoltativo ed è una stringa che rappresenta un fuso orario. Se
omesso, il valore predefinito è "GMT". Puoi specificare i fusi orari utilizzando i valori letterali
stringa. Le opzioni sono:
- Il nome del database TZ, ad esempio "America/Los_Angeles". Per saperne di più, consulta la colonna "Nome database TZ" di questa pagina.
- L'offset del fuso orario rispetto all'UTC, nel formato
(+|-)H[H][:M[M]]
,
ad esempio: "-08:00".
Di seguito sono riportati alcuni esempi di identificatori time_zone validi, che puoi trasmettere come secondo argomento alle funzioni di estrazione dell'ora:
"America/Los_Angeles", or "-08:00". ("PST" is not supported)
"America/New_York", or "-05:00". ("EST" is not supported)
"Europe/London"
"UTC"
"GMT"
Tipi di dati dei parametri
INT
, STRING
Tipo restituito
STRING
Esempi di codice
Esempio 1
In questo esempio, l'argomento time_zone
viene omesso, quindi il valore predefinito è "GMT".
$ts = $e.metadata.collected_timestamp.seconds
timestamp.get_date($ts) = "2024-02-19"
Esempio 2
Questo esempio utilizza un valore letterale stringa per definire time_zone
.
$ts = $e.metadata.collected_timestamp.seconds
timestamp.get_date($ts, "America/Los_Angeles") = "2024-02-20"
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2025-07-29 UTC.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-07-29 UTC."],[[["\u003cp\u003eThe \u003ccode\u003etimestamp.get_date\u003c/code\u003e function extracts the date in \u003ccode\u003eYYYY-MM-DD\u003c/code\u003e format from a Unix timestamp.\u003c/p\u003e\n"],["\u003cp\u003eIt requires an integer representing the Unix timestamp in seconds as input, and can also optionally take a string specifying the time zone.\u003c/p\u003e\n"],["\u003cp\u003eIf the time zone is not specified, the function defaults to "GMT".\u003c/p\u003e\n"],["\u003cp\u003eValid time zone formats include TZ database names like "America/Los_Angeles" or offsets like "-08:00", but abbreviations like "PST" or "EST" are not supported.\u003c/p\u003e\n"],["\u003cp\u003eThe function returns a string representing the date in \u003ccode\u003eYYYY-MM-DD\u003c/code\u003e format.\u003c/p\u003e\n"]]],[],null,["### timestamp.get_date\n\nSupported in: \n[Rules](/chronicle/docs/detection/default-rules) [Search](/chronicle/docs/investigation/udm-search) \n\n timestamp.get_date(unix_seconds [, time_zone])\n\n#### Description\n\nThis function returns a string in the format `YYYY-MM-DD`, representing the day a timestamp is in.\n\n- `unix_seconds` is an integer representing the number of seconds past Unix epoch, such as `$e.metadata.event_timestamp.seconds`, or a placeholder containing that value.\n- `time_zone` is optional and is a string representing a time_zone. If omitted, the default is \"GMT\". You can specify time zones using string literals. The options are:\n - The TZ database name, for example \"America/Los_Angeles\". For more information, see the [\"TZ Database Name\" column from this page](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)\n - The time zone offset from UTC, in the format`(+|-)H[H][:M[M]]`, for example: \"-08:00\".\n\nHere are examples of valid time_zone specifiers, which you can pass as the second argument to time extraction functions: \n\n \"America/Los_Angeles\", or \"-08:00\". (\"PST\" is not supported)\n \"America/New_York\", or \"-05:00\". (\"EST\" is not supported)\n \"Europe/London\"\n \"UTC\"\n \"GMT\"\n\n#### Param data types\n\n`INT`, `STRING`\n\n#### Return type\n\n`STRING`\n\n#### Code samples\n\n##### Example 1\n\nIn this example, the `time_zone` argument is omitted, so it defaults to \"GMT\". \n\n $ts = $e.metadata.collected_timestamp.seconds\n\n timestamp.get_date($ts) = \"2024-02-19\"\n\n##### Example 2\n\nThis example uses a string literal to define the `time_zone`. \n\n $ts = $e.metadata.collected_timestamp.seconds\n\n timestamp.get_date($ts, \"America/Los_Angeles\") = \"2024-02-20\""]]