¥È¥Ã¥×   ÊÔ½¸ º¹Ê¬ ¥Ð¥Ã¥¯¥¢¥Ã¥× źÉÕ Ê£À½ ̾Á°Êѹ¹ ¥ê¥í¡¼¥É   ¿·µ¬ °ìÍ÷ ñ¸ì¸¡º÷ ºÇ½ª¹¹¿·   ¥Ø¥ë¥×   ºÇ½ª¹¹¿·¤ÎRSS

PHP/Æü»þ ¤ÎÊѹ¹ÅÀ

Top / PHP / Æü»þ

[[PHP]]


*¥¿¥¤¥à¥¾¡¼¥óÀßÄê
 date_default_timezone_set('Asia/Tokyo');



*¥¿¥¤¥à¥¹¥¿¥ó¥× [#e5cf3195]
¥µ¡¼¥Ð¾å¤Ç¤Î¡¢1970ǯ1·î1Æü00»þ00ʬ00Éà GMT ¤«¤é¤Î·Ð²áÉÿô~

[[time>http://jp2.php.net/manual/ja/function.time.php]]
 // ¸½ºß¤Î¥¿¥¤¥à¥¹¥¿¥ó¥×¤ò¼èÆÀ
 $iTimeStamp = time();

[[mktime>http://jp2.php.net/manual/ja/function.mktime.php]]
 // »ØÄêÆü»þ¤Î¥¿¥¤¥à¥¹¥¿¥ó¥×¤ò¼èÆÀ
 $iTimeStamp = mktime([int »þ[, int ʬ[, int ÉÃ[, int ·î[, int Æü[, ǯ]]]]]]);

[[gmmktime>http://jp2.php.net/manual/ja/function.gmmktime.php]]
 // GMT»ØÄêÆü»þ¤Î¥¿¥¤¥à¥¹¥¿¥ó¥×¤ò¼èÆÀ
 $iTimeStamp = gmmktime([int »þ[, int ʬ[, int ÉÃ[, int ·î[, int Æü[, ǯ]]]]]]);

[[strtotime>http://jp2.php.net/manual/ja/function.strtotime.php]]
 // »ØÄêʸ»úÎó¤Î¥¿¥¤¥à¥¹¥¿¥ó¥×¤ò¼èÆÀ
 $iTimeStamp = strtotime('2006-09-04 18:34:11')

[[filemtime>http://jp2.php.net/manual/ja/function.filemtime.php]]
 // ¥Õ¥¡¥¤¥ëºÇ½ª¹¹¿·Æü»þ¤Î¥¿¥¤¥à¥¹¥¿¥ó¥×¤ò¼èÆÀ
 $iTimeStamp = filemtime('index.html')



*[[getdate>http://jp2.php.net/manual/ja/function.getdate.php]]¤Ë¤è¤ëÆü»þ¾ðÊó¤Î¼èÆÀ [#p0dda37d]
     /**
      * Æü»þʸ»úÎó¼èÆÀ
      * @param $iTimeStamp ¥¿¥¤¥à¥¹¥¿¥ó¥×
      * @return ¼¡¤Î¤è¤¦¤Êʸ»úÎó¤òÊÖ¤·¤Þ¤¹¡£2008ǯ2·î10Æü(Æü) ¸á¸å7»þ21ʬ26ÉÃ
      */
     function getDateString($iTimeStamp)
     {
         $arStrDayOfTheWeek = array("Æü", "·î", "²Ð", "¿å", "ÌÚ", "¶â", "ÅÚ");
         $arDateInfo = getdate($iTimeStamp);
         $strDayOfTherWeek = $arStrDayOfTheWeek[$arDateInfo['wday']];
         $strReturn = $arDateInfo['year']."ǯ".$arDateInfo['mon']."·î".$arDateInfo['mday']."Æü(".$strDayOfTherWeek.") ";
         if ($arDateInfo['hours'] >= 12) {
             $strReturn .= "¸á¸å";
         } else {
             $strReturn .= "¸áÁ°";
         }
         $strReturn .= ($arDateInfo['hours'] % 12)."»þ".$arDateInfo['minutes']."ʬ".$arDateInfo['seconds']."ÉÃ";
         return $strReturn;
     }
     print getDateString(time())."<br>\n";

*[[date>http://jp2.php.net/manual/ja/function.date.php]]¤Ë¤è¤ëÆü»þʸ»úÎó¤Î¥Õ¥©¡¼¥Þ¥Ã¥È [#e5a5fd31]
 $strDate = date(¥Õ¥©¡¼¥Þ¥Ã¥Èʸ»úÎó[, ¥¿¥¤¥à¥¹¥¿¥ó¥×]);

 // ¸½ºß¤ÎÆü»þ¤òɽ¼¨
 // 2006-09-14 (Thu) 12:20:45
 print date("Y-m-d (D) H:i:s", time())

|¥Õ¥©¡¼¥Þ¥Ã¥È|ÆâÍÆ|Îã|h
|Y|À¾Îñǯ|2011|
|y|À¾Îñǯ²¼£²·å|11|
|m|·î¡§0¥Õ¥£¥ëɽµ­|01¡Á12|
|n|·î¡§¿ô»úɽµ­|1¡Á12|
|F|·î¡§±Ñ¸ìɽµ­|January, ...|
|M|·î¡§£³Ê¸»úɽµ­|Jan, ...|
|j|Æü¡§¿ô»úɽµ­|1¡Á31|
|d|Æü¡§0¥Õ¥£¥ëɽµ­|01¡Á31|
|w|ÍËÆü¡§¿ô»úɽµ­|0:ÆüÍËÆü, 1:·îÍËÆü, ...|
|l|ÍËÆü¡§±Ñ¸ìɽµ­|Sunday, Monday, ...|
|D|ÍËÆü¡§£³Ê¸»úɽµ­|Sun, Mon, ...|
|A|AM¤Þ¤¿¤ÏPM|AM, PM|
|g|»þ´Ö¡§12»þ´Öɽµ­|1¡Á12|
|G|»þ´Ö¡§24»þ´Öɽµ­|1¡Á24|
|h|»þ´Ö¡§12»þ´Ö£°¥Õ¥£¥ëɽµ­|01¡Á12|
|H|»þ´Ö¡§24»þ´Ö£°¥Õ¥£¥ëɽµ­|01¡Á24|
|i|ʬ|00¡Á59|
|s|ÉÃ|00¡Á59|
|u|¥Þ¥¤¥¯¥íÉÃ(PHP 5.2.2¤«¤é)|0¡Á999|



*[[checkdate>http://jp2.php.net/manual/ja/function.checkdate.php]]¤Ë¤è¤ëÆüÉÕ¥Á¥§¥Ã¥¯ [#rf064907]
 checkdate(·î, Æü, ǯ)¤Ç¡¢Â¸ºß¤¹¤ëÆüÉդΤȤ­TRUE¤¬ÊÖ¤ê¤Þ¤¹¡£

 for ($i = 1; checkdate(2, $i, 2008); $i++) {
     print("$i ");
 }



*¥ê¥ó¥¯
-[[PHP ¤Ë¤è¤ëÆüÉÕ¡¦»þ¹ï¡¦»þ´Ö¤Î·×»»¡¦±é»»¤Î¤Þ¤È¤á>http://www.hoge256.net/2007/08/63.html]]
-[[JavaScript ¤Ë¤è¤ëÆüÉÕ¡¦»þ¹ï¡¦»þ´Ö¤Î·×»»¡¦±é»»¤Î¤Þ¤È¤á>http://www.hoge256.net/2007/08/64.html]]