Results 1 to 4 of 4

Thread: How to get date of yesterday in php

  1. #1
    Join Date
    Apr 2009
    Posts
    87

    How to get date of yesterday in php

    I am looking for program in php which display yesterday date. The date function in php is use to calculate the date but what are the syntax need to used in this function so it will display yesterday date. Any recommendations and suggestions are appreciated.

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: How to get date of yesterday in php

    Code:
    <?php
    // yesterday in 'd-m-Y' format
    $ts['yesterday'] = strtotime( '-1 days' ); // or, strtotime( 'yesterday' );
    echo "Yesterday: ", date( 'd-m-Y', $uts['yesterday'] ), "<br />\n";
    
    // the day before yesterday in 'd-m-Y' format
    $ts['day-before-yesterday'] = strtotime( '-2 days' );
    echo "The day before yesterday: ", date( 'd-m-Y', $uts['day-before-yesterday'] ), "<br />\n";
    ?>

  3. #3
    Join Date
    Jan 2009
    Posts
    199

    Re: How to get date of yesterday in php

    To get date of yesterday in php follow the code given below :

    Code:
    $yesterday = date('d/m/y', mktime(0, 0, 0, date("m") , date("d") - 1, date("Y")));
    OR
    Code:
    strtotime("-1 day")

  4. #4
    Join Date
    Dec 2008
    Posts
    177

    Re: How to get date of yesterday in php

    Code:
     $yesterday = strtotime("-1 day"), "\n";
    $yesterday = " ".date("m, Y", $yesterday);
    This will show the correct date of yesterday. mktime is a powerful function that can be used in php or you can also use strtotime.It will calculate by it self the overlapping of the months so this will always show the real yesterday.

Similar Threads

  1. very choppy sound at cutscenes in Yesterday Game
    By Woodward in forum Video Games
    Replies: 3
    Last Post: 16-01-2014, 09:59 AM
  2. Replies: 1
    Last Post: 29-03-2012, 01:05 AM
  3. Yesterday Save Game download and Location
    By Romsy in forum Video Games
    Replies: 1
    Last Post: 29-03-2012, 01:00 AM
  4. Replies: 1
    Last Post: 22-02-2011, 04:03 PM
  5. Replies: 3
    Last Post: 18-10-2010, 10:46 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,577,126.49794 seconds with 16 queries