Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 07-11-2009
Member
 
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.
Reply With Quote
  #2  
Old 07-11-2009
Member
 
Join Date: May 2008
Posts: 2,293
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";
?>
Reply With Quote
  #3  
Old 07-11-2009
Member
 
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")
Reply With Quote
  #4  
Old 07-11-2009
Member
 
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to get date of yesterday in php"
Thread Thread Starter Forum Replies Last Post
very choppy sound at cutscenes in Yesterday Game Woodward Video Games 3 16-01-2014 09:59 AM
Yesterday Game black screen error, only sound coming, no visual display Tau-Mai Video Games 1 29-03-2012 01:05 AM
Yesterday Save Game download and Location Romsy Video Games 1 29-03-2012 01:00 AM
my smps stop working from yesterday which is of 700 W while playing mafia 2 ajay arya Monitor & Video Cards 1 22-02-2011 04:03 PM
Same problem from yesterday Unable to send my aol mail via windows OmJaa Windows Vista Mail 3 18-10-2010 10:46 AM


All times are GMT +5.5. The time now is 07:12 AM.