時間
$this->put("lc_end_time_year", date("Y",strtotime($val))); $this->put("lc_end_time_month", date("m",strtotime($val))); $this->put("lc_end_time_days", date("d",strtotime($val))); date("Y/m/d H:i:s",strtotime("+9 hour", mktime(gmdate("H"), gmdate("i"),gmdate("s"), gmdate("n"), gmdate("j"), gmdate("Y"))) date("Y/m/d H:i:s",strtotime("+14 hour", date("U")))
GMT グリニッジ標準時の変換
print date("Y-m-d- H:i:s", strtotime("+9 hour", strtotime("Fri, 21 Feb 2014 01:39:29")));
時間の追加
時間の変換
$time["Y"] = date("Y",strtotime("2010-10-29 11:46:32")); $time["m"] = date("m",strtotime("2010-10-29 11:46:32")); $time["d"] = date("d",strtotime("2010-10-29 11:46:32")); print_r($time); echo "\n";
5日の追加
$setTime = date("Y/m/d",strtotime("+5 day",mktime(0,0,0, $time["m"],$time["d"],$time["Y"]))); echo $setTime; echo "\n";
2ヶ月追加
$setTime2 = date("Y/m/d",strtotime("+2 month",mktime(0,0,0, $time["m"],$time["d"],$time["Y"]))); echo $setTime2; echo "\n";
1年2ヶ月追加
$setTime3 = date("Y/m/d",strtotime("+2 month 1 year",mktime(0,0,0, $time["m"],$time["d"],$time["Y"]))); echo $setTime3;
連想配列の昇順など
foreach($assgin as $k => $v){ $count[$k] = $v["count"]; } array_multisort($count,SORT_DESC,$assgin);
メールの正規表現
$reg = "/([-_\.a-zA-Z0-9]+\@[-_\.a-zA-Z0-9]+)/";
$timestamp1 = strtotime("last Monday"); //前の月曜日 $timestamp2 = strtotime("next Month"); //再来月 echo date( 'Y年m月d日', $timestamp1 )."<br>\n"; echo date( 'Y年m月d日', $timestamp2 );
strtotime関数
day | 日を表わす |
week | 日を1週間単位で表わす |
month | 月を表わす |
year | 年を表わす |
hour | 時刻を表わす |
minute | 分を表わす |
second | 秒を表わす |
now | 現在時刻を表わす |
tomorrow | +1 day と同様 つまり、「明日」 |
yesterday | -1 day と同様 つまり、「昨日」 |
first | +1 と同様 |
next | +1 と同様※但しバージョン4.4より前のPHPでは、誤って+2として計算されます。 |
last | -1 と同様 |
先月の表示
date("Ym",strtotime("-1 month",strtotime("last Monday")));