April 12th, 2011, 06:25 PM
PHP Time/Date increment once every 7 days
Ok I'm working with dates. I have 7 blocks on the table, the table rotates every 7 days. per week. That part is fine. I also have on that one week table showing 7 days a week that rotate once a week.
How you have an individual date change only once every 7 days for each of the 7 cells on table?
So far I have date set and increment by one, but how do I tell that increment to only happen once every 7days by time i set?
@month [monday 1st][day2][day3][day4]...[sunday 7th],2011
<?php $date = new DateTime("2011-04-11");$date->modify('+1 day');echo $date->format('d');?>
7 days later the php changes the table blocks too
@month [monday the 8th] [tuesday 9th].... [sunday 14th], 2011
April 12th, 2011, 06:39 PM
What dates? What table? What's rotating? Why are you incrementing stuff?
April 12th, 2011, 06:44 PM
because the sql queries are only changed if user desires....
they stay put to show specials for each pertaining day of the week, 7 columns to the tuple "monday-sunday".
The dates will change in 7 table cells once a week only. To express that these specials are taking on these days of the week. 1 for each day of that 7 day cycle.
basically i need 7 different dates to change on once every 7 days.
April 12th, 2011, 06:48 PM
Cell one would me "monday the 1st" and cell 7 would "sunday 7th" then 7 days later those dates in my table will change "monay the 8th" to "sunday the 14th".
So, every 7 days the number would increment to the day of the week in that month. At the end of the month the numbers must know what date it is and to be able to factor right month and begin back on the 1st, (e.g. Tuesday 1st).
The cells can only change once every 7 days and be able to distinct between one from another on addition like i am monday 1st and your second but next week i am monday the 8th.
, but only once every 7 days on starting date i specify.
April 12th, 2011, 07:42 PM
Here's Monday for the current week:
For some custom date,
$monday = new DateTime();
$monday->setTimestamp(mktime(12, 0, 0, 1, date("z") + 2 - date("N"), date("Y")));
(So the only thing different is adding that $date.)
$date = strtotime("2011-04-11");
$monday->setTimestamp(mktime(12, 0, 0, 1, date("z", $date) + 2 - date("N", $date), date("Y", $date)));
Last edited by requinix; April 12th, 2011 at 07:44 PM.
April 13th, 2011, 12:30 PM
When I ran that it didn't work. is there a way you can set the function modify() to only run once every 7 days? The script above I wrote increments it by 7 but everyday... I'm trying to get an increment on my set day only once every 7 days.
April 13th, 2011, 01:45 PM
Not really, no. PHP doesn't remember things. It doesn't know what it did yesterday or what it did last week. You need to find a way to determine stuff at the moment - not according to what happened in the past.
What code did you try?