<?php
date_default_timezone_set('UTC');
$timezone = new DateTimeZone('UTC');     //specify the timezone

$year = 2000;  //where this outputs a simple year 'CCYY'
$day = 245;        //where this provides the day of year

$format = 'Y-z';    //specifying what format i'm creating the datetime with
$date = $year.'-'.($day-1);         //formatting the strings to the above $format

$fileDateStore = DateTime::createFromFormat($format, $date, $timezone);//, $timezone);  //create the DateTime object
$fileDateString = date_format($fileDateStore,"Y-m-d");  //format it so strtotime() can read it

echo "year-DOY: $year-$day<br>\n";
echo 'fileDateString = '.$fileDateString."<br>\n";


/*
$date1 = $year.'-'.($day-1);         //formatting the strings to the above $format
$fileDateStore = DateTime::createFromFormat($format, $date1, $timezone);//, $timezone);  //create the DateTime object
$fileDateString = date_format($fileDateStore,"Y-m-d");  //format it so strtotime() can read it
$fileDate = strtotime($fileDateString);  //finally create the Unix Timestamp for the date.
$newfileDOY = date_format($fileDateStore,"Y-z");
echo 'newfileDOY = '.$newfileDOY.', ';
echo 'date = '.$date.', ';
echo 'fileDateString = '.$fileDateString.', ';
echo 'fileDate = '.$fileDate.PHP_EOL;
*/
?>