--- title: Date slug: Web/HTTP/Headers/Date tags: - General Header - HTTP - Reference - header ---
Date
標頭的值是傳送當下的日期與時間。
注意 Date
被列在 fetch spec 的 forbidden header names 清單中──也就是說這段程式不會送出 Date
標頭:
fetch('https://httpbin.org/get', { 'headers': { 'Date': (new Date()).toUTCString() } })
Header type | {{Glossary("General header")}} |
---|---|
{{Glossary("Forbidden header name")}} | yes |
Date: <day-name>, <day> <month> <year> <hour>:<minute>:<second> GMT
格林威治標準時間的意思。在 HTTP 中日期都是採用 GMT,絕不會顯示當地時間。
Date: Wed, 21 Oct 2015 07:28:00 GMT
new Date().toUTCString() // "Mon, 09 Mar 2020 08:13:24 GMT"
Specification | Title |
---|---|
{{RFC("7231、Date、7.1.1.2")}} | Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content |
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
{{Compat("http.headers.Date")}}