หา เมื่อวานวันที่ สัปดาห์ เดือน ก่อนหน้านี้ ด้วย strtotime ใน PHP


หน้าแรก PHP MySQL เกร็ดความรู้ หา เมื่อวานวันที่ สัปดาห์ เดือน ก่อนหน้านี้ ด้วย strtotime ใน PHP
Find Yesterday’s date
<?php

echo "yesterday was ".date("Y-m-d", strtotime("-1 days"));

?>
Output
yesterday was 2010-04-10

Find Date one week ago
<?php

echo "1 week form today was ".date("Y-m-d", strtotime("-1 weeks"));

?>
Output
1 week form today was 2010-04-04

Find Date one month after
<?php

echo "1 month from today will be ".date("Y-m-d", strtotime("+1 months"));

?>
Output
1 month form today will be 2010-05-11


ขึ้นไปด้านบน