The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 5 of 5

Thread: Time a day before?

  1. #1
    77
    posts
    Registered User

    Time a day before?

    I'm hoping someone can help me.

    Is it possible to take a date from $thedate = date("j F Y");
    and minus a day from that?

    So if it reads 21 January 2008 is it possible to make it read 20 January 2008?

    I would really appreciate some help.

  2. #2
    Are you making the date in the script itself? If so, just use the time() function and subtract 86400 (one day in seconds).
    PHP Code:
    $time date("j F Y"time()-86400); 
    OR

    PHP Code:
    $time date("j F Y"strtotime("yesterday"); 
    If you've only got the output of the date:

    PHP Code:
    $time strtotime($date);
    $date date("j F Y"strtotime("yesterday"$time)); 
    OR

    PHP Code:
    $time strtotime($date);
    $date date("j F Y"$time-86400); 
    Last edited by hl; January 21st, 2008 at 12:11 PM.
    got pwnt?

  3. #3
    77
    posts
    Registered User
    Thanks a million!! I will give it a try. Thanks

  4. #4

    check it

    this code is also very use full to get the date.

    $newDate = date('m-d-Y',mktime(0, 0, 0, date("m") , date("d")-1, date("Y")));

  5. #5
    Quote Originally Posted by kinderjit View Post
    this code is also very use full to get the date.

    $newDate = date('m-d-Y',mktime(0, 0, 0, date("m") , date("d")-1, date("Y")));
    That code is much more convoluted than being able to get the exact same results by doing
    PHP Code:
    $newDate date'm-d-Y'strtotime('yesterday') ); 
    Let us live so that when we come to die even the undertaker will be sorry. - Mark Twain
    Don't PM me your CSS, xHTML, JS or PHP questions. I will not reply to ANY IE6 questions.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012