Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

74 users online



checking expiry

checking expiry

Currently viewing this thread: 1 (0 members and 1 guests)


Page 1 out of 2
digitalerr0r

digitalerr0r

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:


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

BigToach

BigToach

Neversidian
Status: Offline!
PHP:

<?php
if($array['t_stamp'] < strtotime('+1 month')){
        
// good
}
?>

___________________

Neverside Development Director
PHP Snippets
BigToach.com - IT WORKS, TOACHY!

digitalerr0r

digitalerr0r

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

burnfreak666

burnfreak666

Status: Offline!

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

digitalerr0r

digitalerr0r

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

BigToach

BigToach

Neversidian
Status: Offline!
PHP:

<?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!

digitalerr0r

digitalerr0r

Neverside Newbie
Status: Offline!
PHP:


<?php

$select 
MYSQL_QUERY("SELECT * FROM `admin_orders` WHERE `deleted`='0'");
while(
$array MYSQL_FETCH_ARRAY($select)){
    if(
$array['t_stamp'] > strtotime('-2 day')){
        print 
$array['name'] ."Has Less Than 2 Days Left";
    } elseif(
$array['t_stamp'] < strtotime('+1 month')){
        print 
$array['name'] ."Has Expired";
    } else {
        print 
$array['name'] ."Is Valid";
    }
}

?>

Like that?

BigToach

BigToach

Neversidian
Status: Offline!

sorta

PHP:


<?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!

digitalerr0r

digitalerr0r

Neverside Newbie
Status: Offline!

hmm ok well its just saying that everythings expired when its not :-| any ideas?

digitalerr0r

digitalerr0r

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

Page 1 out of 2
Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0103 seconds.