Created
January 8, 2021 05:18
-
-
Save ErMandeep/f90709e90248a6e250ba97fc99eb1a1a to your computer and use it in GitHub Desktop.
last 7 days, last 2 weeks and last 30 days in php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| if( !function_exists( 'pr' ) ) { | |
| function pr() { | |
| foreach( func_get_args() as $e ) { | |
| echo "<pre>"; | |
| print_r( $e ); | |
| echo "</pre>"; | |
| } | |
| } | |
| } | |
| $current_date = date('Y-m-d'); | |
| $yesterday_date = date('Y-m-d', strtotime('-1 day', strtotime($current_date))); | |
| $lastSevenDays = array('from' => date('Y-m-d', strtotime('-7 day', strtotime($current_date))), 'to' => $yesterday_date); | |
| $lastTwoWeeks = array('from' => date('Y-m-d', strtotime('-14 day', strtotime($current_date))), 'to' => $yesterday_date); | |
| $lastMonth = array('from' => date('Y-m-d', strtotime('-30 day', strtotime($current_date))), 'to' => $yesterday_date); | |
| pr( "last Seven Days ========================= ", $lastSevenDays , 'last Two Weeks ========================== ', $lastTwoWeeks, 'last Month ===============================', $lastMonth ); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment