DateTime
PHP Manual

DateTime::format

(PHP 5 >= 5.2.0)

DateTime::formatReturns date formatted according to given format

설명

public string DateTime::format ( string $format )
string date_format ( DateTime $object , string $format )

인수

object

절차식 전용: date_create()가 반환하는 DateTime 객체.

format

Format accepted by date().

반환값

Returns formatted date on success or FALSE on failure.

예제

Example #1 Displaying the date and time using the procedural form

<?php
date_default_timezone_set
('Europe/London');

$datetime date_create('2008-08-03 14:52:10');
echo 
date_format($datetime'jS, F Y') . "\n";
echo 
date_format($datetimeDATE_ATOM);
?>

Example #2 Displaying the date and time using the object oriented form

<?php
date_default_timezone_set
('Europe/London');

$datetime = new DateTime('2008-08-03 14:52:10');
echo 
$datetime->format('jS, F Y') . "\n";
echo 
$datetime->format(DATE_ATOM);
?>
?>

위 예제의 출력:

3rd, August 2008
2008-08-03T14:52:10+01:00

참고


DateTime
PHP Manual