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
    Regular Coder
    Join Date
    Dec 2010
    Location
    Kent, UK
    Posts
    573
    Thanks
    23
    Thanked 10 Times in 10 Posts

    displaying test for 15 minutes every day from 3.45am till 4am

    i just need to display the wirds "backup Soon" every day between 3.45am and 4am to let users know that hte site will be shutting down so that it can back up. it will only last 15 minutes, but im a bit confused as to how i would do this, i was thinking of using the time() function, but then remembered that that is the current time just like the NOW() function (i believe im correct, but if not please correct me) so what would be the best way to do this?

    Cheers.

    Dan
    http://360-tactics.co.uk/forum/index.php

    Crime-Wave

    please post your code wrapped in tags
    please post your PHP wrapped in tags

  • #2
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,535
    Thanks
    45
    Thanked 259 Times in 256 Posts
    The date() function. Mind you, the following is sloppy, and I suspect there may be better ways to do it, but meh :P

    PHP Code:
    if (intval(date('G')) == && intval(date('i')) >= 45 || date('Gi') == '400'//do whatever 

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,619
    Thanks
    0
    Thanked 645 Times in 635 Posts
    Why do you need to shut the site down in order to back up? If it is a database you are backing up then using the appropriate backup processes allow the database to be backed up without needing to take it offline.

    After all, with the way the internet works your proposed offline time is right in the middle of peak usage time somewhere in the world.
    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
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Quote Originally Posted by felgall View Post
    Why do you need to shut the site down in order to back up? If it is a database you are backing up then using the appropriate backup processes allow the database to be backed up without needing to take it offline.
    Agreed. There really isn't a huge necessity to down the site at any given time; the concurrency issues of an active site IMO isn't worth the offline time to snapshot it to include all changes. Depending on what you use to backup the data, you may also be able to detect the running status of the process and use that to effectively show a simple notice that a backup is occurring so the site may be slower than usual.

    After all, with the way the internet works your proposed offline time is right in the middle of peak usage time somewhere in the world.
    Loved that, and its so very true. World wide can sure be a pain at times

    For your original question though, I'd use strtotime in conjunction with time(). I'm all about building code to be as easily changeable as possible, so if all of a sudden you decide you only need to do it once a week or ever two weeks, strtotime is a lot easier to change than the picking apart the time and comparing.
    PHP Code:
    $iStartRange strtotime('03:45');
    $iEndRange strtotime('04:00');
    $iTime time();
    if (
    $iTime >= $iStartRange && $iTime <= $iEndRange)
    {
        print 
    'in that time range';

    strtotime will use the current date if you only provide a time. You can of course manufacture it for things like the second thursday of the month for example.

  • #5
    Regular Coder
    Join Date
    Dec 2010
    Location
    Kent, UK
    Posts
    573
    Thanks
    23
    Thanked 10 Times in 10 Posts
    well its a game, so instead of people still playing and changing the database whilst its backing up, which could be an average player ammount of 400 - 800 players clicking/ doing an action every second, i believed that it could take some time to back up, and to stop them changing the database whilst its backing up i believed this would be the best way.
    http://360-tactics.co.uk/forum/index.php

    Crime-Wave

    please post your code wrapped in tags
    please post your PHP wrapped in tags


  •  

    Posting Permissions

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