
June 18th, 2004
04:39 AM
Neverside Newbie
Status: Offline!
checking expiry
hey,
i have a order script, and when you add it you have to specify when the order expires from a dropdown, either, 1month, 6months or 1year. when the order is added the db gets a timestamp aswell using ' time(); '. Im checking weather its expired with..
1month example:
<?php
$month = (30*24*60*60);
if($array['t_stamp'] < time() - $month){
print "Expired!";
} else {
print "Valid!";
}
?>
But i think this is inaccurate as some months have 31 days etc..
Whats the easiest way of checking expiry like that....
1. how can i check time left until expires in months, weeks, days, hrs, mins, secs....
2. and how can i do a check to show a warning if thers less than 2 days left?
thanks
digi

June 18th, 2004
04:37 PM
Neversidian
Status: Offline!
<?php
if($array['t_stamp'] < strtotime('+1 month')){
// good
}
?>
___________________
Neverside Development Director
PHP Snippets
BigToach.com - IT WORKS, TOACHY!

June 19th, 2004
12:01 AM
Neverside Newbie
Status: Offline!
rite, so thats a better way of doing that, but how could i check the ones with < than 2 days left and print a warning for them... ?
thanks
digi

June 19th, 2004
12:51 AM
I'm not sure what exactly you are trying to do.
But date scripts can be a little tricky sometimes.
Since I'm not sure what you are trying to do, trying looking at the date function on php.net
___________________
AHHH!!!!!! THIS SCRIPT IS REALLY MAKING ME MAD!!!

June 19th, 2004
01:02 AM
Neverside Newbie
Status: Offline!
heh the date function is meant to be used for printing the date/time so you can read it. e.g Jun 11 - 18.36pm
i need to use a timestamp because with my company certain offers expire after a set time. so i need to place a timestamp when the order is processed ( which im doing ) then have a script check any upcoming expirations when i login to the admin cp. if there are any upcoming ones i need to be able to click it and show how long is left until it expires ( days, hours, minutes etc.. ).

June 19th, 2004
06:04 PM
Neversidian
Status: Offline!
<?php
if($array['t_stamp'] > strtotime('-2 day')){
// either expired or less than 2 days left
}
?>
___________________
Neverside Development Director
PHP Snippets
BigToach.com - IT WORKS, TOACHY!

June 19th, 2004
07:39 PM
Neversidian
Status: Offline!
sorta
<?php
$select = MYSQL_QUERY("SELECT * FROM `admin_orders` WHERE `deleted`='0'");
while($array = MYSQL_FETCH_ARRAY($select)){
if($array['t_stamp'] < strtotime('+1 month')){
print $array['name'] ."Has Expired";
} else {
print $array['name'] ."Is Valid";
if($array['t_stamp'] > strtotime('-2 day')){
print " But has less than 2 days left.";
}
}
}
?>
___________________
Neverside Development Director
PHP Snippets
BigToach.com - IT WORKS, TOACHY!

June 23rd, 2004
12:22 AM
Neverside Newbie
Status: Offline!
hmm ok well its just saying that everythings expired when its not :-| any ideas?

June 23rd, 2004
12:41 AM
Neverside Newbie
Status: Offline!
heh im just really confused now, ive tried loads of different things. :confused:
ok, ill say it again, what would be the simpleist way of setting an expiry length when an order is placed, then have a simple way of checking if its expired / not expired and show the ones that have expired. also, how to simply check if less than 2 days are left, and print them again?
thanks,
digi