| |||||||
This is a discussion on CRON jobs... within the Technical Help forums, part of the Off Topic category; I assume this is going to be CRON jobs unless you gurus can think of another way of doing this. ...
![]() |
| | Thread Tools |
| | #1 |
| iPod 30gb Join Date: Aug 2009 Location: Widnes
Posts: 1,090
![]() | CRON jobs...I assume this is going to be CRON jobs unless you gurus can think of another way of doing this. Basically I am making a sales tracking system that when a colleague submits a sale it cascades into daily and weekly, now the week numbers change every week (oddly enough) and I need a way of making the system know that the week number has changed. I was thinking having a file called week.php with a variable in say $week which would equal "1" then in a weeks time the CRON job can add it by going to week.php?add=1 the problem is I don't know how to tell the CRON job to do that. So basically how to I make cPanel visit week.php?add=1 every week automatically. Thanks!
__________________ Totally Free iPad | McFlurry Ice Cream Van Everything I say reflects my own opinions and not that of any company. |
|
| | #2 |
| Mini Mac | Huh? Seems like a silly way of doing things if you ask me. Why not calculate what week it is using the time() function? |
|
| | #3 |
| iPod 30gb Join Date: Aug 2009 Location: Widnes
Posts: 1,090
![]() | Because that would mean me knowing what all our dates are and I don't need the start date just a number that the week is on i.e 1/1/2001 is week one 8/1/2001 is week 2. All I need is the week number, I suppose the time and date thing would work as well but I had a nightmare trying to figure that one out last time.
__________________ Totally Free iPad | McFlurry Ice Cream Van Everything I say reflects my own opinions and not that of any company. |
|
| | #4 |
| Mini Mac | What about something like this? Code: <?php
define('START_DATE', '1st January 2001');
function week_query($date)
{
$diff = strtotime($date) - strtotime(START_DATE);
$weeks = ($diff > 0) ? floor($diff / 604800) + 1 : 0;
return $weeks;
}
echo week_query('8th January 2001'); // 2
echo week_query('1st February 2003'); // 109
echo week_query('8th January 2000'); // 0 (negative time difference always returns 0)
|
|
| | #5 |
| iPod 30gb Join Date: Aug 2009 Location: Widnes
Posts: 1,090
![]() | You sir are simply amazing - the old thing I had got off a coding website was at least 15times as long as that. Just goes to show how good eXceemers are!
__________________ Totally Free iPad | McFlurry Ice Cream Van Everything I say reflects my own opinions and not that of any company. |
|
| | #6 | ||
| Mini Mac | Quote:
Quote:
Last edited by chigley; 09-09-11 at 07:10 PM.. | ||
|
![]() |
| Thread Tools | |
| |