date only provide current date, but how i can get what day was yesterday or what day will be in 2 days?!
The function's syntax is: date ( string $format [, int $timestamp ] ) PHP: So the below code will output tomorrow's date: echo date($format, time()+24*60*60*1); PHP: Where 1 is the number of days that you want it to give or take off the current date. Can also be a negative number as well. Hope that helps!
Please use this function int mktime ([ int $hour = date("H") [, int $minute = date("i") [, int $second = date("s") [, int $month = date("n") [, int $day = date("j") [, int $year = date("Y") [, int $is_dst = -1 ]]]]]]] ) this function will use for your requirements you can edit dates to this function
Try strtotime. It recognizes short phrases to calculate prior or future dates. -1 day, +23 hours, +2 years, etc. $yesterday = strtotime("-1 day"); // returns UNIX time $yesterday = date("F d, Y", $yesterday); // returns Month dd, YYYY // or to consolidate it into one line $yesterday = date("F d, Y", strtotime("-1 day")); Code (php):
you can also do something like this to get yesterday, - 1 year // Can have multiple strtotime in the same line echo date('F d, Y',strtotime("-1 Day",strtotime("-1 year"))); PHP: