How to run a php function in the specified date ?
Moderator: General Moderators
- christian_phpbeginner
- Forum Contributor
- Posts: 136
- Joined: Sat Jun 03, 2006 2:43 pm
- Location: Java
How to run a php function in the specified date ?
Hey folks,
I am hosting my web at http://www.ueuo.com, but the problem is that it is only limited to 200MB. Somehow, I am letting my user to contact me, and then again. Because it's only limited to 200mb, I want to create a function that deletes all emails after 48 hours, automatically. Now, I can create the function but don't know how to execute and where to put it ??
Thanks a lot,
Chris
I am hosting my web at http://www.ueuo.com, but the problem is that it is only limited to 200MB. Somehow, I am letting my user to contact me, and then again. Because it's only limited to 200mb, I want to create a function that deletes all emails after 48 hours, automatically. Now, I can create the function but don't know how to execute and where to put it ??
Thanks a lot,
Chris
- DaveTheAve
- Forum Contributor
- Posts: 385
- Joined: Tue Oct 03, 2006 2:25 pm
- Location: 127.0.0.1
- Contact:
pickle | Please use
Understand?
pickle | Please use[/syntax]
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
[syntax="php"]
$offset = 172800; //60secs * 60 Minutes * 24 hours * 2 Days
if($emails[$i]['timestamp'] < (time()-$offset)) {
//Delete Email
}
pickle | Please use[/syntax]
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]-
impulse()
- Forum Regular
- Posts: 748
- Joined: Wed Aug 09, 2006 8:36 am
- Location: Staffordshire, UK
- Contact:
I may not fully understand so don't be offended by my questioning - But doesn't you code say that if the e-mails time stamp is below 48 hours then it deletes the e-mail?DaveTheAve wrote:$offset = 172800; //60secs * 60 Minutes * 24 hours * 2 Days
if($emails[$i]['timestamp'] < (time()-$offset)) {
//Delete Email
}
Understand?
Regards,
-
impulse()
- Forum Regular
- Posts: 748
- Joined: Wed Aug 09, 2006 8:36 am
- Location: Staffordshire, UK
- Contact:
I may have not woken up fully yet but doesn't that say that the e-mail is not older than 48 hours, meaning the e-mail shouldn't be deleted?volka wrote:If it is smaller than "now minus 48 hours" (time()-$offset)impulse() wrote:But doesn't you code say that if the e-mails time stamp is below 48 hours then it deletes the e-mail?
Yet again, sorry if I'm being obtuse, I just hate not understanding something
- christian_phpbeginner
- Forum Contributor
- Posts: 136
- Joined: Sat Jun 03, 2006 2:43 pm
- Location: Java
Thanks
Hi folks, thanks a lot, but the question is where to put the function ? Thank you !
Some hosts allow you to set up cron jobs - automatic script execution at a pre-defined, recurring time. You could put this function in a script, then call that script in a cron job. Ask your host about cron jobs.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
- christian_phpbeginner
- Forum Contributor
- Posts: 136
- Joined: Sat Jun 03, 2006 2:43 pm
- Location: Java