#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    125
    Rep Power
    5

    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?

    PHP Code:
    <?php $date = new DateTime("2011-04-11");$date->modify('+1 day');echo $date->format('d');?>
    @month [monday 1st][day2][day3][day4]...[sunday 7th],2011

    7 days later the php changes the table blocks too

    @month [monday the 8th] [tuesday 9th].... [sunday 14th], 2011
  2. #2
  3. Come play with me!
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,746
    Rep Power
    9397
    What?

    What dates? What table? What's rotating? Why are you incrementing stuff?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    125
    Rep Power
    5
    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.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    125
    Rep Power
    5
    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.

    PHP Code:
    modify('+7 day'); 
    , but only once every 7 days on starting date i specify.
  8. #5
  9. Come play with me!
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,746
    Rep Power
    9397
    Here's Monday for the current week:
    PHP Code:
    $monday = new DateTime();
    $monday->setTimestamp(mktime(12001date("z") + date("N"), date("Y"))); 
    For some custom date,
    PHP Code:
    $date strtotime("2011-04-11");
    $monday->setTimestamp(mktime(12001date("z"$date) + date("N"$date), date("Y"$date))); 
    (So the only thing different is adding that $date.)
    Last edited by requinix; April 12th, 2011 at 06:44 PM.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    125
    Rep Power
    5
    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.
  12. #7
  13. Come play with me!
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,746
    Rep Power
    9397
    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?

IMN logo majestic logo threadwatch logo seochat tools logo