...

View Full Version : displaying test for 15 minutes every day from 3.45am till 4am



Dan13071992
03-01-2012, 03:56 PM
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

Keleth
03-01-2012, 04:14 PM
The date() (http://php.net/manual/en/function.date.php) function. Mind you, the following is sloppy, and I suspect there may be better ways to do it, but meh :P


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

felgall
03-01-2012, 09:14 PM
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.

Fou-Lu
03-02-2012, 12:38 AM
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.


$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.

Dan13071992
03-02-2012, 06:12 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum