วันอาทิตย์ที่ 15 ธันวาคม พ.ศ. 2556

php เพิ่มวัน - เดือน - ปี ในการแสดงผล

บวกวันเพิ่ม
  1. $datedate = date ("Y-m-d", strtotime("+1 day", strtotime($date)));
บวกเดือนเพิ่ม
  1. $datedate = date ("Y-m-d", strtotime("+1 month", strtotime($date)));
บวกปีเพิ่ม
  1. $datedate = date ("Y-m-d", strtotime("+1 year", strtotime($date)));  
<?php
echo date('Y-m-d', strtotime('+1 month'))."";
echo date('Y-m-d',strtotime("now"))."
"
;
echo date('Y-m-d',strtotime("10 September 2000"))."
"
;
echo date('Y-m-d',strtotime("+1 day"))."
"
;
echo date('Y-m-d',strtotime("+1 week"))."
"
;
echo date('Y-m-d',strtotime("+1 week 2 days 4 hours 2 seconds"))."
"
;
echo date('Y-m-d',strtotime("next Thursday"))."
"
;
echo date('Y-m-d',strtotime("last Monday"))."
"
;
echo date("Y-m-d H:i:s", mktime(date("H"), date("i")+0, date("s")+0, date("m")+0 , date("d")+0, date("Y")+0))."
"
;
?>
<?php
echo date('Y-m-d',strtotime('+1 month'))."<br>";
echo date('Y-m-d',strtotime("now"))."<br>";
echo date('Y-m-d',strtotime("10 September 2000"))."<br>";
echo date('Y-m-d',strtotime("+1 day"))."<br>";
echo date('Y-m-d',strtotime("+1 week"))."<br>";
echo date('Y-m-d',strtotime("+1 week 2 days 4 hours 2 seconds"))."<br>";
echo date('Y-m-d',strtotime("next Thursday"))."<br>";
echo date('Y-m-d',strtotime("last Monday"))."<br>";
echo date("Y-m-d H:i:s", mktime(date("H"), date("i")+0, date("s")+0, date("m")+0  , date("d")+0, date("Y")+0))."<br>";
?>