時間と数字のフォーマット
2014/07/02
教わったのでメモ。
・時間の整形
strtotime()
例)
$ymd = '2013-1-2';
echo date( 'Y-m-d', strtotime($ymd) );
結果)
2013-01-02
・リファレンス
http://php.net/manual/ja/function.strtotime.php
英文形式の日付を Unix タイムスタンプに変換する
英文形式ってのがよく分からないけど、下記が
サポートする日付みたい。
http://www.php.net/manual/ja/datetime.formats.php
------
・数字の整形
sprintf()
例)
$i = 1;
echo sprintf( "%02d", $i );
結果)
01
・リファレンス
http://php.net/manual/ja/function.sprintf.php
フォーマットされた文字列を返す
パラメーター等は下記がなんとなく分かりやすい
http://memopad.bitter.jp/w3c/php/func_string_sprintf.html
関連記事
-
-
PHPでファイル書き込み時に「failed to open stream: HTTP~~」エラー
PHPでファイルを書き込む際に「failed to open stream: H ...
-
-
FPDIで「This PDF document probably uses~~」エラーの対処方法
FPIDであるPDFを読み込ませようとすると「This PDF document ...
-
-
PHP8系で「Uncaught TypeError: count(): Argument」エラーの対応方法
PHP8系で「PHP Fatal error: Uncaught TypeErr ...
-
-
PHPにて「ImageHash」ライブラリを使用し画像の類似度を算出する方法
以前にPHPの「image-comparator」ライブラリで画像の類似度を算出 ...
-
-
jQuery.uploadでリアルタイムプレビュー
やりたい事は、 ・<input type="file">で画像を選択 ...