関数 strtotime
関数 strtotime は任意の
日付をタイムスタンプ形式に変換します。タイムスタンプ形式
は、1970年1月1日から指定された時点までに経過した
秒数です。
構文
strtotime(string $datetime, ?int $baseTimestamp = null): int|false
例
日付 '2025-12-31'
をタイムスタンプに変換してみましょう:
<?php
echo strtotime('2025-12-31');
?>
コードの実行結果:
1767128400
例
2000年9月10日
をタイムスタンプに変換してみましょう:
<?php
echo strtotime('10 September 2000');
?>
コードの実行結果:
968529600
例
明日の日付(深夜0時)を タイムスタンプ形式で出力してみましょう:
<?php
echo strtotime('Tomorrow');
?>