I know the year and the day of year (0-365). Is there any way to get back from it to timestamp?
Something like:
$day=date('z');
$year=2012;
$timestamp=strtotime($day.'-nd day of '.$year);
Try the following:
$timestamp = mktime(0,0,0,1,$day,$year);
It will produce a timestamp where the time is set to 0:00:00. (I am not sure if it will behave correctly with respect to daylight savings though...)
Check the PHP manual for further details: PHP: mktime - Manual
Maybe strtotime gets handy here:
php -r 'echo @date("Y-m-d H:s", strtotime("january 2012 +200 day")).PHP_EOL;'
In your example $timestamp = strtotime("january $year +$day day");
Try using createFromFormat :
$date = DateTime::createFromFormat('z Y', $day . ' ' . $year);
echo $date->getTimestamp();