Manual:wfTimestamp/ja

This page is a translated version of the page Manual:WfTimestamp and the translation is 72% complete.

概要

wfTimestamp() (GlobalFunctions.php の一部) は、MediaWiki タイムスタンプUNIX タイムスタンプ、MySQL DATETIME 書式、RFC 2822 書式など、一般的なタイムスタンプ書式間で変換する機能を提供します。 完全な一覧は下記の書式を参照してください。

タイムスタンプは、タイムゾーンなし、または特定の書式で指定された GMT タイムゾーンで出力されます。

データベースにタイムスタンプを挿入する際は、絶対に wfTimestamp() を使用しないでください。 これにより PostgreSQL が破損します (おそらく他の非 MySQL データベースも)。 代わりに $dbw->timestamp() を使用してください

使用法

wfTimestamp( $output_format, $timestamp )
  • 引数 $output_format で指定された書式の文字列型のタイムスタンプを返します。
  • $output_format の引数で正しくない書式が渡された場合は MWException をスローします。
  • $timestamp 引数で無効または認識できないタイムスタンプが渡された場合、false を返します。
引数 既定 注記
$output_format TS_UNIX formats の表に記載されている定数のいずれかである必要があります。
$timestamp 現在の日時 Should be a literal timestamp (e.g. 2010-12-03 22:07:25). Any format listed in the formats table can be used.
Call with no arguments to return the current time in UNIX time format.

echo wfTimestamp(); // 1712337895

Call with one argument to return the current time in the specified format.

echo wfTimestamp( TS_ISO_8601 ); // 2024-04-05T17:24:55Z

Call with two arguments to return an arbitrary timestamp in the specified format.

タイムスタンプは、wfTimestamp() が出力できる任意の書式であることに注意してください。

$timestamp = 20240455172455; echo wfTimestamp( TS_ISO_8601, $timestamp ); // 2024-04-05T17:24:55Z $timestamp = '2024-04-05T17:24:55Z'; echo wfTimestamp( TS_RFC2822, $timestamp ); // Fri, 05 Apr 2024 17:24:55 GMT

書式

種類 定数 書式[1] 注記
MySQL DATETIME TS_DB Y-m-d H:i:s 2024-04-05 17:24:55
DB2 TS_DB2 Y-m-d H:i:s 2024-04-05 17:24:55 gerrit:50764 で除去されました
MediaWiki バージョン:
1.15 – 1.20
Exif TS_EXIF Y:m:d H:i:s 2024:04:05 17:24:55 Shouldn't ever be used, but is included for completeness. [2]
ISO 8601 (タイムゾーンなし) TS_ISO_8601 Y-m-d\TH:i:s\Z 2024-04-05T17:24:55Z Special:Export および API で使用されます
ISO 8601 基本 (タイムゾーンなし) TS_ISO_8601_BASIC Ymd\THis\Z 20240405T172455Z ResourceLoader で使用されます
MediaWiki TS_MW YmdHis 20240405172455
Oracle TS_ORACLE d-m-Y H:i:s.000000 05-04-2024 17:24:55.000000 phab:rSVN51500 より前は 'd-M-y h.i.s A' . ' +00:00' でした
PostgreSQL TS_POSTGRES Y-m-d H:i:s+00 2024-04-05 17:24:55+00 gerrit:459601 より前は 'Y-m-d H:i:s' . ' GMT' でした
RFC 2822 TS_RFC2822 D, d M Y H:i:s Fri, 05 Apr 2024 17:24:55 GMT For email and HTTP headers
UNIX time TS_UNIX U 1712337895 Number of seconds since 1970-01-01 00:00:00 UTC
  1. Formatting codes per PHP's date() function.
  2. Documented on page 28 (for the DateTime tag) and page 36 (for the DateTimeOriginal and DateTimeDigitized tags) of the Exif 2.2 specification. Download the specification at http://exif.org/Exif2-2.PDF

関連項目