I am using a search option for retrieving data from database. The search criteria is between two dates. The default 'to date' is current system date and is using date() function. I want to set default 'from date' by 30 days less than current date. For example my 'To date, is 22-12-2014 then 'From date' be 22-11-2014. How can it set in php?
try this
$to_date = date('d-m-Y');
$from_date = date('d-m-Y',strtotime("-1 month")); // or -30 days
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.