svn: /phpdoc/en/trunk/reference/datetime/datetime/ construct.xml
| From: | Hannes Magnusson | Date: | Thu, 04 Mar 2010 10:46:30 +0000 |
| Subject: | svn: /phpdoc/en/trunk/reference/datetime/datetime/ construct.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-6169@lists.php.net to get a copy of this message | ||
bjori Thu, 04 Mar 2010 10:46:30 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=295817
Log:
Add an example of howto create a DateTime object from a unix timestamp
Changed paths:
U phpdoc/en/trunk/reference/datetime/datetime/construct.xml
Modified: phpdoc/en/trunk/reference/datetime/datetime/construct.xml
===================================================================
--- phpdoc/en/trunk/reference/datetime/datetime/construct.xml 2010-03-04 06:21:19 UTC (rev 295816)
+++ phpdoc/en/trunk/reference/datetime/datetime/construct.xml 2010-03-04 10:46:30 UTC (rev 295817)
@@ -66,6 +66,20 @@
]]>
</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>
</para>
</refsect1>