prudens Posted June 5, 2008 Share Posted June 5, 2008 Hi. $yesterday=date("Y-m-d",mktime(0,0,0,date("m"),date("d")-1,date("Y"))); I have a question, I used a "date("d")-1" in the above expression to indicate yesterday. It works well with almost everything, but I wonder if it will work with say, 05-01-08, or 06-01-08? The first day of months... because 01 - 1 is 00... does PHP auto adjust that or I have to do it manually? Link to comment https://forums.phpfreaks.com/topic/108793-mktime/ Share on other sites More sharing options...
MatthewJ Posted June 5, 2008 Share Posted June 5, 2008 <?php $yest = mktime(0,0,0,05,01 - 1, 2008); echo date("Y-m-d", $yest); ?> Outputs 2008-04-30 for me Link to comment https://forums.phpfreaks.com/topic/108793-mktime/#findComment-558082 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.