(PHP 5 >= 5.2.0, PHP 7)
DateTime::format -- DateTimeImmutable::format -- DateTimeInterface::format -- date_format — Returns date formatted according to given format
객체 기반 형식
$format
)$format
)$format
)절차식 형식
Returns date formatted according to given format.
object
절차식 전용: date_create()가 반환하는 DateTime 객체.
format
Format accepted by date().
Returns the formatted date string on success실패 시 FALSE
를 반환합니다.
Example #1 DateTime::format() example
객체 기반 형식
<?php
$date = new DateTime('2000-01-01');
echo $date->format('Y-m-d H:i:s');
?>
절차식 형식
<?php
$date = date_create('2000-01-01');
echo date_format($date, 'Y-m-d H:i:s');
?>
위 예제의 출력:
2000-01-01 00:00:00
This method does not use locales. All output is in English.