開發 Dashboard 時,需要一些時間變化,這時可以靠 strtotime 來幫忙轉,十分方便
$ cat /tmp/t.php
<?php
echo date("Y/m/d")."\n";
echo date("Y/m/d", strtotime(date("Y/m/d")." -1 day"))."\n";
echo date("Y/m/d", strtotime(date("Y/m/d")." -2 day"))."\n";
echo date("Y/m/d", strtotime(date("Y/m/d")." -7 day"))."\n";
echo date("Y/m/d", strtotime(date("Y/m/d")." -8 day"))."\n";
echo date("Y/m/d", strtotime(date("Y/m/d")." -30 day"))."\n";
echo date("Y/m/d", strtotime(date("Y/m/d")." -31 day"))."\n";
echo date("Y/m/d", strtotime(date("Y/m/d")." -60 day"))."\n";
$ php /tmp/t.php
2018/10/22
2018/10/21
2018/10/20
2018/10/15
2018/10/14
2018/09/22
2018/09/21
2018/08/23
沒有留言:
張貼留言