개발 스크랩 메모/PHP
Php 연중 무휴로 이동하는 방법
렉사이
2020. 12. 14. 02:39
일년 중 제인 날부터 지금까지 php 을 어떻게 사용합니까?
getdatefromday(275, 2012)
그 출력 날짜.
나도 상반된 일을 할 것이다.
예를 들면 GetDayofYear (‘2012년10월21일 ’이다.
대답
이 모든 것이 매우 쉽다.
이 곳에서 datetime 대상을 읽는 createfromformat 정적 방법, 이곳의 date 함수와 이곳의 strotime 함수.
// 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'));