寫了那麼久的php我到今天才發現原來日期的增減這麼簡單!
看到之前自己寫的函式才發現自己真的很蠢!哈
```php
$currentDate = date("Y-m-d");// current date
echo "Current Date: ".$currentDate;
$date30DaysAdded = date('Y-m-d', strtotime("+30 days"));
echo "30 Days added: ".$date30DaysAdded;
$date10YearsBack = date('Y-m-d', strtotime("-10 years"));
echo "10 Years back: ".$date10YearsBack;
$date2DaysAdded = date('Y-m-d', strtotime("+2 days"));
echo "2 Days Added: ".$date2DaysAdded;
```
沒有留言:
張貼留言