Weiss Posted September 6, 2017 Share Posted September 6, 2017 Suppose i wanna make a page where a customer enters, and he will see the days of the next week, like if im entering the page today (wednesday september 6th) i will see a table with the following week, starting from sunday september 10th to saturday september 17th. is there a way php can do such thing? Link to comment Share on other sites More sharing options...
dsonesuk Posted September 6, 2017 Share Posted September 6, 2017 Use string to time function strtotime(), you can multitude textual expression to get the result you want, then loop through each day by increasing by 1 in a loop // set initial start date to next sunday from current date $date = date("Y-m-d", strtotime("next Sunday")); //set from $date value to 1 week ahead for end date $end_date = date("Y-m-d", strtotime("+1 week", strtotime($date))); //'2020-12-31'; while (strtotime($date) <= strtotime($end_date)) { echo $date . "<br>"; //increment to next day $date = date("Y-m-d", strtotime("+1 day", strtotime($date))); } 1 Link to comment Share on other sites More sharing options...
Weiss Posted September 6, 2017 Author Share Posted September 6, 2017 waow thanx very much Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now