// get current year using php
<?php echo date("Y"); ?>
$currentYear=date("Y");//2019
$year = date("y",strtotime($mydate));
date('Y')
// current year
<?php echo date("Y"); ?>
// current month
<?php echo date("m"); ?>
// current day
<?php echo date("d"); ?>
Get the current year using PHP:
<?php
echo date("Y");
?>
echo date('Y', $date);
// This should get you a DateTime object from the date and year.
function getDateFromDay($dayOfYear, $year) {
$date = DateTime::createFromFormat('z Y', strval($dayOfYear) . ' ' . strval($year));
return $date;
}
// This should get you the day of the year and the year in a string.
date('z Y', strtotime('21 oct 2012'));