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 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jul 2007
    Posts
    571
    Thanks
    25
    Thanked 28 Times in 28 Posts

    Is this a job for PHP or JavaScript or Both??

    I need a Timer that counts down from 1hr, Once it gets to zero I need an event to happen (ex: output hello) then it will restart in an endless loop.

    It thould be in the following format:

    1:00:00
    59:59
    59:58
    ext....

  • #2
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    JavaScript will allow you to count on a local computer's browser - so somebody will need to be viewing the page during the countdown for the event to occur. Javascript gives you power to do stuff on the client side. PHP gives you power to do stuff on the server side. If you need something to occur every hour regardless of who is looking at the site or how long they are, use a cron job with PHP.

    It really depends on what the timer is linked to, what event you want to occur, and if its client or server side.
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #3
    Regular Coder
    Join Date
    Jul 2007
    Posts
    571
    Thanks
    25
    Thanked 28 Times in 28 Posts
    yes, i want the event to happen even if nobody is on the site.
    so i guess it is php

  • #4
    Regular Coder
    Join Date
    Jun 2007
    Location
    Los Angeles
    Posts
    545
    Thanks
    81
    Thanked 5 Times in 5 Posts
    I you just need something to happen once an hour, a cron job script could do this. Are you on a Linux server? If so, then you can write a PHP script and add it to your crontab to execute once an hour.

    If you need the webpage to show an active count down, then you will need to do this using Javascript - when JS count down reaches 0 it will call a PHP script on your server to do something and then call the html web page again which will start the visable count down again.
    RalphF
    Business Text Messaging Services
    https://www.MobileTextingService.com

  • #5
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    Here is a good introduction to cron jobs

    http://www.sitepoint.com/article/introducing-cron

    If you aren't on Linux or have access to cron jobs, you can have pseudo cron jobs

    http://www.bitfolge.de/pseudocron-en.html
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #6
    Regular Coder
    Join Date
    Jul 2007
    Posts
    571
    Thanks
    25
    Thanked 28 Times in 28 Posts
    thanks for the help, I'm gonna look into it now :-)


  •  

    Posting Permissions

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