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

Tags: , , , ,

Sponsored Links



How to get date of yesterday in php

Software Development


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
Zecho's Avatar
Member
 
Join Date: May 2008
Posts: 2,267
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


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
Baseline Column Date automatically updates Finish Date Adam 1980 Microsoft Project 3 18-05-2011 07:08 PM
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 nufcquigs Windows Vista Mail 4 18-10-2010 11:46 AM
Windows Media Player won't play ANY music it played yesterday hmboomer Media Player 1 25-06-2010 04:01 AM
Changing start date and creating formula for finish date Lisa M Microsoft Project 2 11-09-2006 06:10 PM


All times are GMT +5.5. The time now is 04:00 AM.