Maracles Posted October 27, 2009 Share Posted October 27, 2009 I have a table in which every row is a consecutive day i.e. row 1 is 'July 1st', row 2 is 'July 2nd' and so forth. The first column is for actual date in the format of; dd-mm-yy, the second column is day; Mon, Tue and so forth. There are 28 rows for every table i.e. 28 days. The table is created by a for loop and the first date is based on a variable I have called $startdate (the start date changes depending on the page the table is on). I would like help with a code that does two things. 1. Every time the for loop creates a new row I need the date in the first column to increase by one so that each row has the next sequential date, however I need it to take into account the yearly calendar i.e. when it gets to 28th February the next date should be 1st March. 2. The second column simply needs show the days but in line with the actual date. I have tried using an array but can't seem to get it work properly, is this the correct way or is there something better I should be using? If any one can help it would be much appreciated. The big about getting in line with the yearly calendar is what's throwing me off in particular. Quote Link to comment https://forums.phpfreaks.com/topic/179274-solved-dates-and-array-issue/ Share on other sites More sharing options...
seanlim Posted October 28, 2009 Share Posted October 28, 2009 Use the PHP date function. For each loop, add the number of seconds in a day and pass the new timestamp as the second parameter. EDIT: Add the number of seconds in a day *cumulatively* Quote Link to comment https://forums.phpfreaks.com/topic/179274-solved-dates-and-array-issue/#findComment-945937 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.