이 기사의 예에서는 PHP 날짜 함수 date를 사용하여 UNIX 시간 형식을 지정하는 방법을 설명합니다. 참고할 수 있도록 모든 사람과 공유하세요. 구체적인 분석은 다음과 같습니다.
날짜 함수는 지정된 형식에 따라 Unix 시간을 원하는 텍스트 출력 형식으로 지정할 수 있습니다
사용된 함수 구문은 다음과 같습니다
string date (string $Format); string date (string $Format, int $Time);
다음은 데모 코드입니다
<?php echo "When this page was loaded,\n"; echo 'It was then ', date ('r'), "\n"; echo 'The currend date was ', date ('F j, Y'), "\n"; echo 'The currend date was ', date ('M j, Y'), "\n"; echo 'The currend date was ', date ('m/d/y'), "\n"; echo 'The currend date was the ', date ('jS \o\f M, Y'), "\n"; echo 'The currend time was ', date ('g:i:s A T'), "\n"; echo 'The currend time was ', date ('H:i:s O'), "\n"; echo date ('Y'); date ('L')?(print ' is'):(print ' is not'); echo " a leap year\n"; echo time ('U'), " seconds had elapsed since January 1, 1970.\n"; ?>
출력 결과는 다음과 같습니다
It was then Sat, 26 Dec 2009 07:09:51 +0000 The currend date was December 26, 2009 The currend date was Dec 26, 2009 The currend date was 12/26/09 The currend date was the 26th of Dec, 2009 The currend time was 7:09:51 AM GMT The currend time was 07:09:51 +0000 2009 is not a leap year 1261811391 seconds had elapsed since January 1, 1970.
이 기사가 모든 사람의 PHP 프로그래밍 설계에 도움이 되기를 바랍니다.