Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Oct 2007
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb If the time now is a new hour then...

    Hi,

    Im trying to think of a way to write a piece of code that basiaclly does this.

    If the time now is a new hour then...
    If the time now is a new day then...
    if the time is a new week then...
    if the time now is a new month then...

    once I have that I can create mysql tables at the right time to store data.

    Thanks in advance!

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts

  • #3
    New Coder
    Join Date
    Apr 2007
    Posts
    89
    Thanks
    1
    Thanked 2 Times in 2 Posts
    you could use a cookie. I'm still learning php so I can't code this with out referring to a manual. But...

    create an array with hour, day, week, month ($now)

    if cookie exists then read data into array $then, else create cookie with $now

    then test the arrays against each other
    Last edited by psykx; 11-08-2007 at 01:21 AM.

  • #4
    New Coder
    Join Date
    Apr 2007
    Posts
    89
    Thanks
    1
    Thanked 2 Times in 2 Posts
    PHP Code:
    if ($now['hour'] = ($then['hour'] + foo))
    {
    do 
    hour thing

    where foo is the int of one hour or whatever time
    etc...
    Last edited by psykx; 11-08-2007 at 01:23 AM. Reason: Adding etc...

  • #5
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    It depends on how you want the content changed. If you want something to execute for each user as the hour/whatever changes use a cookie. If you want all users to affect it then you just need to store the time in a file(preferably) or database, and compare it when the page loads. file_put_contents() file_get_contents() time()


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •