LoginSignup
7
7

More than 5 years have passed since last update.

phpの時間関係

Last updated at Posted at 2013-05-20

strtotimeの引数とかで使えるの

パラメータ
+1 months 1ヵ月後
+1 week 1週間後
+1 day 1日後
+1 hours 1時間後
+1 minutes 1分後
+1 seconds 1秒後

monthsとか怖くて使ったことないけど。

DateTest.php
<?

// Y-m-d H:i:sの形式で時間取得
$time = date("Y-m-d H:i:s", $_SERVER['REQUEST_TIME']);

// 1分後の時間
$time = date("Y-m-d H:i:s", strtotime("+1 minutes"));

// 文字列からフォーマットを指定 20130501が$timeに入る
$time = date("Ymd", strtotime("2013-05-01 17:00:00"));

// 2013-05-01 17:00:00をすぎたらなんかしたい場合
if(strtotime("2013-05-01 17:00:00") < $_SERVER['REQUEST_TIME']){
    // なんか
}

?>

ここらへん毎度忘れる。

7
7
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
7
7