DateTime::format
(PHP 5 >= 5.2.0)
DateTime::format — Returns date formatted according to given format
Descrierea
public string DateTime::format
( string $format
)
Parametri
- object
-
Doar pentru stilul procedural: Un obiect DateTime întors de funcţia date_create()
- format
-
Format accepted by date().
Valorile întroarse
Returns formatted date on success sau FALSE în cazul eşecului.
Exemple
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($datetime, DATE_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);
?>
?>
Exemplul de mai sus va afişa:
3rd, August 2008 2008-08-03T14:52:10+01:00
DateTime::format
There are no user contributed notes for this page.
