Get yesterday date PHP

Wednesday, September 14, 2011

Here is the different way of Getting yesterday date with PHP
using strtotime() and mktime()  we can find the previous date in easy way.

# Using strtotime() function
// from Current Date
echo date("d-m-Y",strtotime("yesterday"));

# Using mktime() function
// from Specific date  eg: Oct-01-2011
echo date("d-m-Y",mktime(0,0,0,10,1,2011)-1);


Output:
13-09-2011
30-09-2011



No comments:

Post a Comment