Convert day of the year to datetime in php

后端 未结 2 840
抹茶落季
抹茶落季 2021-01-29 10:44

I have value

$days = 166.0444; 

which is day of the year. How can I simply convert this value to its datetime, which should be



        
2条回答
  •  猫巷女王i
    2021-01-29 11:02

    If its the current year, you can

    $days = 166.0444;
    $date = new DateTime();
    $date->setDate($date->format('Y'), 1, 1);
    $date->add(new DateInterval('P' . floor($days) . 'D'));
    

提交回复
热议问题