Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
timestamp.as_unix_seconds
timestamp.as_unix_seconds(timestamp [, time_zone])
Deskripsi
Fungsi ini menampilkan bilangan bulat yang merepresentasikan jumlah detik setelah epoch Unix untuk string stempel waktu yang diberikan.
timestamp
adalah string yang merepresentasikan stempel waktu epoch yang valid. Formatnya harus
%F %T
.
time_zone
bersifat opsional dan merupakan string yang merepresentasikan zona waktu. Jika
dihapus, defaultnya adalah GMT
. Anda dapat menentukan zona waktu menggunakan literal string. Opsinya adalah sebagai berikut:
- Nama database TZ, misalnya
America/Los_Angeles
. Untuk mengetahui informasi selengkapnya, lihat
daftar zona waktu database tz di Wikipedia.
- Offset zona waktu dari UTC, dalam format
(+|-)H[H][:M[M]]
,
misalnya: "-08:00".
Berikut adalah contoh penentu time_zone
yang valid, yang dapat Anda teruskan sebagai argumen kedua ke fungsi ekstraksi waktu:
"America/Los_Angeles", or "-08:00". ("PST" is not supported)
"America/New_York", or "-05:00". ("EST" is not supported)
"Europe/London"
"UTC"
"GMT"
Jenis data parameter
STRING
, STRING
Jenis hasil yang ditampilkan
INT
Contoh kode
Contoh 1
Stempel waktu epoch yang valid
timestamp.as_unix_seconds("2024-02-22 10:43:00") = 1708598580
Contoh 2
Stempel waktu epoch yang valid dengan zona waktu America/New_York
timestamp.as_unix_seconds("2024-02-22 10:43:00", "America/New_York") = 1708616580
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-07-29 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-07-29 UTC."],[[["\u003cp\u003eThis function, \u003ccode\u003etimestamp.as_unix_seconds\u003c/code\u003e, converts a given timestamp string into the number of seconds past the Unix epoch.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003etimestamp\u003c/code\u003e input must be a string in the \u003ccode\u003e%F %T\u003c/code\u003e format, while the optional \u003ccode\u003etime_zone\u003c/code\u003e input is a string representing a time zone, defaulting to GMT if omitted.\u003c/p\u003e\n"],["\u003cp\u003eValid \u003ccode\u003etime_zone\u003c/code\u003e formats include TZ database names like "America/Los_Angeles" or offsets like "-08:00", but abbreviations such as "PST" are not supported.\u003c/p\u003e\n"],["\u003cp\u003eThe function's return type is an integer (\u003ccode\u003eINT\u003c/code\u003e) and it is supported in both Rules and Search functionalities.\u003c/p\u003e\n"]]],[],null,["### timestamp.as_unix_seconds\n\nSupported in: \n[Rules](/chronicle/docs/detection/default-rules) [Search](/chronicle/docs/investigation/udm-search) \n\n timestamp.as_unix_seconds(timestamp [, time_zone])\n\n#### Description\n\nThis function returns an integer representing the number of seconds past a Unix epoch for the given timestamp string.\n\n- `timestamp` is a string representing a valid epoch timestamp. The format needs to be `%F %T`.\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 as follows:\n - The TZ database name, for example `America/Los_Angeles`. For more information, see the [list of tz database time zones on Wikipedia](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`STRING`, `STRING`\n\n#### Return type\n\n`INT`\n\n#### Code samples\n\n##### Example 1\n\nValid epoch timestamp \n\n timestamp.as_unix_seconds(\"2024-02-22 10:43:00\") = 1708598580\n\n##### Example 2\n\nValid epoch timestamp with the America/New_York time zone \n\n timestamp.as_unix_seconds(\"2024-02-22 10:43:00\", \"America/New_York\") = 1708616580"]]