LoginSignup
2
2

More than 5 years have passed since last update.

PHPの日付処理

Posted at

公式 http://jp1.php.net/manual/ja/function.date.php

MySQLの日付書式で現在の日付を表示する

echo date('Y-m-d H:i:s');

2013-04-17 23:01:01 こんな感じ

1日前とかの計算

// UNIX timestampで返る
echo strtotime("-1 day");
// 基準日を設定できる
echo strtotime("-1 day", unix_timestamp);

// フォーマットする
echo date("Y-m-d", strtotime("-1 day"));
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2