f:id:tenman:20090506114932p:image


時刻関数 php メモ

<?php
/**
 * 月末
 *
 *
 */
$lastday = mktime(0, 0, 0, 3, 0, 2009);
echo strftime("Last day in Feb 2000 is: %d", $lastday);

$day = date("t", mktime(0, 0, 0, 2 + 1, 0, 2009) );
echo $day;

echo date('y-m-t');
echo 'date("t")'.date('t',strtotime('2009-2'));
/**
 * 現在の週月曜日
 *
 *
 */

$timestamp = strtotime("last Monday"); 

echo date( 'Y年m月d日', $timestamp )."<br>\n";
/**
 * 来月の今日
 *
 *
 */
$timestamp = strtotime("next Month"); //来月
echo date( 'Y年m月d日', $timestamp );

/**
 * ○日後
 *
 * 2009-05-02
 * 2009-05-02
 */
 
echo date("Y-m-d", mktime(0, 0, 0,date('m'), 1 + 1, date('y')));

$date = new DateTime("2009-05-01");
$date->modify("+1 day");
echo $date->format("Y-m-d");


/**
 * RFC2811 フォーマット
 *
 * Sun, 03 May 2009 00:00:00 +0900
 */

echo date("r",strtotime("2009-5-3 00:00:00"));

/**
 * RFC822 フォーマット
 *
 * Wed, 06 May 09 11:06:57 +0900
 *  Fri, 18 Jul 08 16:30:30 +0900
 */
echo date(DATE_RFC822);

$date = new DateTime("18-July-2008 16:30:30");
echo $date->format(DATE_RFC822);


/**
 * DATE_ATOM
 *
 * 2009-05-01T00:00:00+09:00
 */
echo date(DATE_ATOM, mktime(0, 0, 0, 5, 1, 2009));

$date = new DateTime("18-July-2008 16:30:30");
echo $date->format(DATE_ATOM);



exit;

?>