ユーザ用ツール

サイト用ツール

Writing /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/lei_wiki/data/cache/3/3818fb8a3640a685899f60f313ecc849.i failed
Unable to save cache file. Hint: disk full; file permissions; safe_mode setting.
Writing /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/lei_wiki/data/cache/3/3818fb8a3640a685899f60f313ecc849.metadata failed

よく使うphpのその4
Writing /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/lei_wiki/data/cache/3/3818fb8a3640a685899f60f313ecc849.i failed
Unable to save cache file. Hint: disk full; file permissions; safe_mode setting.
Writing /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/lei_wiki/data/cache/3/3818fb8a3640a685899f60f313ecc849.xhtml failed

時間

 $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")));
よく使うphpのその4.txt · 最終更新: 2014/02/21 16:24 by luis_lee