Skip to content

Instantly share code, notes, and snippets.

@syamgot
Last active April 11, 2017 09:22
Show Gist options
  • Save syamgot/01531ce21031488086bc93b81a27bd4d to your computer and use it in GitHub Desktop.
Save syamgot/01531ce21031488086bc93b81a27bd4d to your computer and use it in GitHub Desktop.
[PHP]先月,今月,来月
<?php
for ($i = 1; $i <= 12; $i++) {
echo '先月:' . date('Y-m-t', strtotime(date("Y-$i-01") . '-1 month')) . "\n";
echo '当月:' . date('Y-m-t', strtotime(date("Y-$i-01"))) . "\n";
echo '来月:' . date('Y-m-t', strtotime(date("Y-$i-01") . '+1 month')) . "\n";
echo "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment