#1
  1. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    5
    Rep Power
    0
    how to set expire date like in clasified ads manner, for 7 days, 14 days so on?
    thanks in advance

    ------------------
    great hope of palembang ,indonesia
  2. #2
  3. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,642
    Rep Power
    4492
    What kind of system are you using, what is your code?

    You can use the mktime() function to find a date in the future pretty easily

    $offset = 5 //offset is months
    $future_time = mktime(date("G"),date("i"),date("s"),date("m")+$offset,date("d"),date("Y"));

    That will create a date and time five months in the future.

    Hope that helps.

    ---John Holmes...

    ------------------
    *************************************************************
    * The manual can probably answer 90% of your questions...
    *
    * PHP Manual. www.php.net/manual
    * MySQL Manual: www.mysql.com/documentation/mysql/bychapter
    *************************************************************
  4. #3
  5. No Profile Picture
    Robert_J_Sherman
    Guest
    Devshed Newbie (0 - 499 posts)
    Sure seems like the long way of doing it.

    Let's just say you wanted to set you expire date "90 days" from today.. you can
    get a date by simply doing this:

    $daystoexpire = '90';
    $expires = time() + (86400 * $daystoexpire);

    $expires will now hold the "unix timestamp"
    for your expiration date.

    Now that will be a number like: 8472819002
    or something, actually right now the number will probably begin with a nine.

    Anyway, to transform that into a readable human form, you'll want to pass it through
    the "date()" function, like:
    Date("m d y",$expires);

    That will give it to you like we humans are used to reading time.

    Additionally, if you then wanted to determine wether or not to display the classified, you'd use a simple comparrison, like:
    $today = time();
    if ($today >= $expires) { show it.. }

    Granted, you can use mktime() as well..

    In case you are wondering why "86400", this is because there are 86,400 seconds in a 24 hour period.

    Hope this helps.

    ------------------
    SnR Graphics,
    Low Cost Hosting and Web Development.

    [This message has been edited by Robert_J_Sherman (edited October 17, 2000).]
  6. #4
  7. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    5
    Rep Power
    0
    i need that expire date for making my server
    weight get less,for my music(music news) that i stored at mysql server, i using win98,apache,php4 and mysql 3.23.23
    thanks

    ------------------
    great hope of palembang ,indonesia

Similar Threads

  1. Replies: 7
    Last Post: March 17th, 2004, 05:39 AM
  2. How to see the Memory used by a PHP script?
    By Pardall in forum PHP Development
    Replies: 4
    Last Post: February 13th, 2004, 03:54 PM
  3. Make PHP bypass .htaccess
    By DatNigz2002 in forum PHP Development
    Replies: 2
    Last Post: February 4th, 2004, 12:27 PM
  4. database date selection problem
    By kidsleep in forum MySQL Help
    Replies: 0
    Last Post: January 31st, 2004, 10:50 AM
  5. Replies: 4
    Last Post: January 28th, 2004, 08:29 AM

IMN logo majestic logo threadwatch logo seochat tools logo