Add an example of howto create a DateTime object from a unix timestamp

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@295817 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Hannes Magnusson 2010-03-04 10:46:30 +00:00
parent 75c3613337
commit 772012190e

View file

@ -63,6 +63,20 @@ date_default_timezone_set('Europe/London');
$datetime = new DateTime('2008-08-03 14:52:10');
echo $datetime->format(DATE_ATOM);
?>
]]>
</programlisting>
</example>
<example>
<title>Creating <classname>DateTime</classname> from a UNIX timestamp</title>
<para>
To create a <classname>DateTime</classname> object from a UNIX timestamp
use the <function>strtotime</function> <literal>@</literal> keyword.
</para>
<programlisting role="php">
<![CDATA[
$timestamp = $_SERVER["REQUEST_TIME"];
$dt = new DateTime("@$timestamp");
]]>
</programlisting>
</example>