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
    Mar 2007
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Date JavaScript/PHP

    So I've got a date and on a set interval I want my page to redirect and not do anything more

    My interval will be 10 minutes of active time on my site. I may also want to pause this time!

    I have two options

    1. Have a JavaScript date and save it in my mySQL database but the interval would need to be set against something ?

    2. Have a PHP date and use AJAX to keep my interval up to date. When my interval is up I would return an AJAX response to redirect my page. How can I do this?

    A simple window.location or is there a better way?

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    I'm missing something. Why is this not a simple JS countdown timer?

    Do you mean that the use has 10 minutes total, possibly spread across multiple sessions? So 3 minutes today, 2 minutes tomorrow, 5 minutes next week??
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,471
    Thanks
    0
    Thanked 634 Times in 624 Posts
    Why are you using setInterval instead of setTimeout if you only want the delay once?

    A setInterval of 10 minutes will run the specified function every ten minutes.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    I doubt that he even know that setInterval() exists. I think was just using "set interval" in the sense of "a set amount of time". But who knows.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,471
    Thanks
    0
    Thanked 634 Times in 624 Posts
    Quote Originally Posted by Old Pedant View Post
    I think was just using "set interval" in the sense of "a set amount of time". But who knows.
    Well if people insist on using builtin JavaScript function names when they don't actually mean those functions then the question is even more confusing and meaningless.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

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