I’m not really sure what to call this. But basically I want to be able to have a user click on “Popular Stories from This Week”, and it will take them to a page that will have other stuff but mainly the dates. For example, July 10-17.
I’m currently using this code:
$seven_days_ago = date('j') - 7;
$time_span = date('F ' . $seven_days_ago . ' - j');
Now, I ran into a problem when we entered July, because it would display something like July -3 – 4. I need a way for it to detect if the seven days ago variable is negative, and figure out what it should display. Help?
Thanks!
You can use
strtotimefor this:The above gives me “June 28 – July 5” for
$time_span.