勉強したことのメモ

Webエンジニア / プログラマが勉強したことのメモ。

時間と数字のフォーマット

   2014/07/02  PHP

教わったのでメモ。

・時間の整形
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

  関連記事

Fatal error: [] operator not supported for stringsの対処

Fatal error: [] operator not supported f ...

jQueryとprototypeの共存

prototypeを先に使っているがjQueryに移行してきている ページで、尚 ...

PHPでdo-while(0)構文を利用する際のメリット

あるソースコード上にdo-whileという構文が使われていた。見たことのない構文 ...

CodeIgniter4 & jQueryを用いて同一サイト内でajax通信する方法

CodeIgniter4.4.4 & jQueryを用いて同一サイト内で ...

セレクトメニューとテキストエリアの連動

やりたかった事は、 ・セレクトメニューで何れかを選択すると連動したテキストエリア ...