ย้อนหลัง หรือ เดินหน้า ด้วย mktime()

เช่น ต้องการย้อนหลังไป 2 วัน
code

<?php$month=date("m");

$day=date("d")-2; //ย้อนหลังไป 2 วัน

$year=date("Y");

$mk_data=mktime(0, 0, 0, $month, $day, $year);

echo date("d-m-Y", $mk_data);

?>

จากโค้ดคือเอา 2 ไป”ลบ – ” วัน หากจะเดินหน้าให้เป็น “บวก +” แทน

$day=date("d")+2;

ส่วนเดือน และปีก็รูปแบบเดียวกันกับ วันนะครับ

$month=date("m")-4;
$year=date("Y")-2;
You can leave a response, or trackback from your own site. Responses are currently closed, but you can trackback from your own site. You can skip to the end and leave a response. Pinging is currently not allowed. Both comments and pings are currently closed.
Powered by WordPress | Shop Free T-Mobile Phones Online | Thanks to Verizon Phones without Contract, MMORPG Games and Sell Car