eXceem

Go Back   eXceem > Off Topic > Technical Help

Claim your amazing £1,000 slots booster bonus now!


CRON jobs...

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

Reply
 
Thread Tools
Old 09-09-11, 03:19 PM   #1
iPod 30gb
 
Join Date: Aug 2009
Location: Widnes
Posts: 1,090
cono1717 is a jewel in the rough

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.
 
Reply With Quote
Old 09-09-11, 03:42 PM   #2
Mini Mac
 
chigley's Avatar
 
Join Date: Sep 2006
Location: Bolton/London (home/uni.)
Posts: 8,424
chigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond repute
Send a message via MSN to chigley
Huh? Seems like a silly way of doing things if you ask me.

Why not calculate what week it is using the time() function?
 
Reply With Quote
Old 09-09-11, 04:58 PM   #3
iPod 30gb
 
Join Date: Aug 2009
Location: Widnes
Posts: 1,090
cono1717 is a jewel in the rough
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.
 
Reply With Quote
Old 09-09-11, 05:08 PM   #4
Mini Mac
 
chigley's Avatar
 
Join Date: Sep 2006
Location: Bolton/London (home/uni.)
Posts: 8,424
chigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond repute
Send a message via MSN to chigley
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)
Something for you to play with at least
 
Reply With Quote
Old 09-09-11, 06:50 PM   #5
iPod 30gb
 
Join Date: Aug 2009
Location: Widnes
Posts: 1,090
cono1717 is a jewel in the rough
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.
 
Reply With Quote
Old 09-09-11, 07:10 PM   #6
Mini Mac
 
chigley's Avatar
 
Join Date: Sep 2006
Location: Bolton/London (home/uni.)
Posts: 8,424
chigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond repute
Send a message via MSN to chigley
Quote:
Originally Posted by cono1717 View Post
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!
Haha, no worries I'm not sure what exact format your dates are in, but you'll want to pay attention to this:

Quote:
Originally Posted by PHP Manual strtotime()
Dates in the m/d/y or d-m-y formats are disambiguated by looking at the separator between the various components: if the separator is a slash (/), then the American m/d/y is assumed; whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed.

To avoid potential ambiguity, it's best to use ISO 8601 (YYYY-MM-DD) dates or DateTime::createFromFormat() when possible.

Last edited by chigley; 09-09-11 at 07:10 PM..
 
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off





All times are GMT. The time now is 09:01 PM.
All trademarks and copyrights held by respective owners. Forum posts are owned by the poster.

Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO
no new posts