<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>関数 &#8211; WordPress Memo</title>
	<atom:link href="https://blog.riverforest-wp.info/tag/%E9%96%A2%E6%95%B0/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.riverforest-wp.info</link>
	<description>WordPress に関する覚え書き</description>
	<lastBuildDate>Fri, 09 May 2025 12:48:52 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://blog.riverforest-wp.info/wp-content/uploads/2018/05/cropped-icon-256x256-1-32x32.png</url>
	<title>関数 &#8211; WordPress Memo</title>
	<link>https://blog.riverforest-wp.info</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>WordPress 5.3 で導入される日時の関数とフィルター</title>
		<link>https://blog.riverforest-wp.info/wp5-3-datetime-function-filter/</link>
		
		<dc:creator><![CDATA[Katsushi Kawamori]]></dc:creator>
		<pubDate>Wed, 25 Sep 2019 15:17:37 +0000</pubDate>
				<category><![CDATA[Filter]]></category>
		<category><![CDATA[data_i18n]]></category>
		<category><![CDATA[フィルターフック]]></category>
		<category><![CDATA[日時]]></category>
		<category><![CDATA[関数]]></category>
		<guid isPermaLink="false">https://blog.riverforest-wp.info/?p=1663</guid>

					<description><![CDATA[はじめに WordPress 5.3 は１１月にリリース予定ですが、以下の様な記事を見つけました。 新しい日時の関数とフィルターが導入されるという事で、日時の関数とフィルターを多数使用している自分のプラグイン Warek [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h3 class="wp-block-heading">はじめに</h3>



<p><strong>WordPress 5.3</strong> は１１月にリリース予定ですが、以下の様な記事を見つけました。</p>



<figure class="wp-block-embed is-type-rich is-provider-wp-oembed-blog-card wp-block-embed-wp-oembed-blog-card"><div class="wp-block-embed__wrapper">
<blockquote class="wp-embedded-content" data-secret="8aYw9W3vQE"><a href="https://make.wordpress.org/core/2019/09/23/date-time-improvements-wp-5-3/">Date/Time component improvements in WordPress 5.3</a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  title="&#8220;Date/Time component improvements in WordPress 5.3&#8221; &#8212; Make WordPress Core" src="https://make.wordpress.org/core/2019/09/23/date-time-improvements-wp-5-3/embed/#?secret=JOD72wi6JV#?secret=8aYw9W3vQE" data-secret="8aYw9W3vQE" width="500" height="282" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
</div></figure>



<p>新しい日時の関数とフィルターが導入されるという事で、日時の関数とフィルターを多数使用している自分のプラグイン <strong>Wareki</strong> をベータ版でテストした所、動作しない箇所があったので修正しました。その際に、いろいろテストしたので一部の関数とフィルターを以下に紹介します。</p>



<div class="pluginstatsview-card-wrap">
	<div>
		<img decoding="async" src="https://ps.w.org/wareki/assets/icon-256x256.png?rev=2061943" alt="Wareki のアイコン" class="pluginstatsview-card-icon" />
		<div class="pluginstatsview-after-icon">
			<div class="pluginstatsview-bold"><a href="https://wordpress.org/plugins/wareki/" class="pluginstatsview-astyle">Wareki</a></div>
			<div class="pluginstatsview-small">日付のフォーマット、投稿、コメント、アーカイブ、カレンダーに元号を含む日本の暦を追加します。</div>
			<div class="pluginstatsview-small">作者: <a href="https://profiles.wordpress.org/katsushi-kawamori/">Katsushi Kawamori</a></div>
			<div style="clear: both;"></div>
		</div>
	</div>
	<div style="clear: both;"></div>

	<div class="pluginstatsview-small">
		<span class="pluginstatsview-card-left"><a href="https://wordpress.org/plugins/wareki/#reviews" title="5.0(5点満点中)" class="pluginstatsview-astyle">	<span class="pluginstatsview-stars">
					<span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span>
			</span>
	</a>(3)</span>
		<span class="pluginstatsview-card-right">最終更新: 2日 前</span>
	</div>
	<div class="pluginstatsview-small">
		<span class="pluginstatsview-card-left">200以上サイトで有効化中</span>
		<span class="pluginstatsview-card-right">検証済み: 7.0</span>
	</div>
	<div class="pluginstatsview-small">
		<span class="pluginstatsview-card-left">ダウンロード: <a href="https://downloads.wordpress.org/plugin/wareki.2.03.zip" class="dashicons dashicons-download pluginstatsview-download"></a></span>
		<span class="pluginstatsview-card-right">リリース: 2019-04-02</span>
	</div>
	<div class="pluginstatsview-small pluginstatsview-card-center">
		2026-03-31 09:30 時点の統計	</div>
</div>



<h3 class="wp-block-heading">関数</h3>



<pre class="prism line-numbers"><code class="language-php language-html">wp_date( $format, $timestamp = null, $timezone = null )</code></pre>



<p> <strong>date_i18n</strong> 関数の後継だと思います。 </p>



<ul class="wp-block-list">
<li>第１引数 PHP の日時のフォーマット</li>



<li>第２引数 Unix タイムスタンプ</li>



<li>第３引数 タイムゾーン</li>



<li>返り値 書式化された日時の文字列もしくは False</li>
</ul>



<p>第３引数がポイントでデフォルトではサイトで設定したタイムゾーンが入ってきます。使い方は以下の様に書きます。現在の日時を出すだけなら、第２引数・第３引数は省略します。</p>



<pre class="prism line-numbers"><code class="language-php language-html">$date_ux = 1569422086;
$date = wp_date( 'Y-m-d H:i:s', $date_ux, new DateTimeZone( 'UTC' ) );</code></pre>



<p>
以前 <strong>data_i18n</strong> 関数では、前後のコード次第で９時間ずれたりして苦労した事があったのですが、この関数ではそのような事はなくなりました。

</p>



<figure class="wp-block-embed is-type-rich is-provider-wp-oembed-blog-card"><div class="wp-block-embed__wrapper">
https://wpdocs.osdn.jp/%E9%96%A2%E6%95%B0%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/date_i18n
</div></figure>



<hr class="wp-block-separator has-css-opacity"/>



<pre class="prism line-numbers"><code class="language-php language-html">current_datetime()</code></pre>



<p>以下の様な日時のオブジェクトを返します。</p>



<pre class="prism line-numbers"><code class="language-php language-html">DateTimeImmutable Object ( &#91;date] =&gt; 2019-09-25 23:34:46.584458 &#91;timezone_type] =&gt; 3 &#91;timezone] =&gt; Asia/Tokyo ) </code></pre>



<h3 class="wp-block-heading">フィルター</h3>



<pre class="prism line-numbers"><code class="language-php language-html">apply_filters( 'wp_date', $date, $format, $timestamp, $timezone )</code></pre>



<ul class="wp-block-list">
<li>第１引数 書式化された日時の文字列</li>



<li>第２引数 PHP の日時のフォーマット</li>



<li>第３引数 Unix タイムスタンプ</li>



<li>第４引数 タイムゾーン返り値 日時の文字列もしくは False </li>
</ul>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
