We often need to get start date and end date while executing database queries. Many of us waste time with complex and nested functions to achieve such simple solution.
PHP has a built-in function date(), and this function is very useful in figuring out date as well as selecting proper format. Many developers utilize the selectors such as ‘Y‘, ‘m‘, ‘d‘, ‘h‘, ‘i‘, ‘s‘ to get a generic datetime value but not everyone knows that there’s another selector, called ‘t‘.
The ‘t‘ inside date() function returns total number of days in a current month.
var $num_days = date('t');