php get previous month Name code example Example 1: php get year <?php echo date("Y"); ?> Example 2: php get current year $currentYear=date("Y");//2019