$tommorow = date_i18n('Y-m-d', strtotime("tomorrow"));
echo<<<EOF
<script>
jQuery(function($){
if($('.wpcf7-date').length){
$('.wpcf7-date').attr('min', '{$tommorow}');
}
});
</script>
fanctions.phpにこう書いています。
こんにちは
strtotime() の第2引数のデフォルトは time() の値になります。
ローカルタイムの場合は、time() の代わりに current_time() を使います。
$tommorow = date( 'Y-m-d', strtotime( 'tomorrow', current_time( 'timestamp' ) ) );
または
$tommorow = date( 'Y-m-d', current_time( 'timestamp' ) + 60 * 60 * 24 );
ご返信ありがとうございます!
ちなみに最初はjQueryを使わず、
function cf7_change_min_date($content) {
if( is_admin() ) return $content;
$today = date_i18n('Y-m-d'); // Asia/Tokyo の今日の日付
$tommorow = date_i18n('Y-m-d', strtotime("tomorrow")); // Asia/Tokyo の明日の日付
// minの値が$today(東京の今日の日付)だったら、$tommorow(東京の明日の日付)に置換して返す
$content = str_replace('min="' . $today . '"', 'min="' . $tommorow . '"', $content);
return $content;
}
こんな感じに書いたのですが、これもうまく動かず時間が変にずれてしまったのは、current_time()を使っていないからでしょうか?
こんな感じに書いたのですが、これもうまく動かず時間が変にずれてしまったのは、current_time()を使っていないからでしょうか?
はい、strtotime() の第2引数を省略しているので UTC タイムになります。
なるほどですね!
ありがとうございます。
助かりました(❁ᴗ͈ˬᴗ͈))