php date year code example
Example 1: php get year
<?php echo date("Y"); ?>
Example 2: php get current year
$currentYear=date("Y");//2019
Example 3: php grab year from date
$year = date("y",strtotime($mydate));
Example 4: date in php
/**
* Its always best to use a datetime object
*/
$dateTime = new \DateTime();
/**
* You can get the string by using format
*/
$dateTime->format('Y-m-d H:i:s');
Example 5: php date
$dateTime = new \DateTime();
/**
* You can get the string by using format
*/
$dateTime->format('Y-m-d H:i:s');