<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Return current Unix timestamp</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.strtotime.html">strtotime</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.timezone-abbreviations-list.html">timezone_abbreviations_list</a></div> <div class="up"><a href="ref.datetime.html">Date/Time Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.time" class="refentry"> <div class="refnamediv"> <h1 class="refname">time</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">time</span> — <span class="dc-title">Return current Unix timestamp</span></p> </div> <div class="refsect1 description" id="refsect1-function.time-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">int</span> <span class="methodname"><strong>time</strong></span> ( <span class="methodparam">void</span> )</div> <p class="para rdfs-comment"> Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT). </p> </div> <div class="refsect1 examples" id="refsect1-function.time-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-2325"> <p><strong>Example #1 <span class="function"><strong>time()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />$nextWeek </span><span style="color: #007700">= </span><span style="color: #0000BB">time</span><span style="color: #007700">() + (</span><span style="color: #0000BB">7 </span><span style="color: #007700">* </span><span style="color: #0000BB">24 </span><span style="color: #007700">* </span><span style="color: #0000BB">60 </span><span style="color: #007700">* </span><span style="color: #0000BB">60</span><span style="color: #007700">);<br /> </span><span style="color: #FF8000">// 7 days; 24 hours; 60 mins; 60secs<br /></span><span style="color: #007700">echo </span><span style="color: #DD0000">'Now: '</span><span style="color: #007700">. </span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">'Y-m-d'</span><span style="color: #007700">) .</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #DD0000">'Next Week: '</span><span style="color: #007700">. </span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">'Y-m-d'</span><span style="color: #007700">, </span><span style="color: #0000BB">$nextWeek</span><span style="color: #007700">) .</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #FF8000">// or using strtotime():<br /></span><span style="color: #007700">echo </span><span style="color: #DD0000">'Next Week: '</span><span style="color: #007700">. </span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">'Y-m-d'</span><span style="color: #007700">, </span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #DD0000">'+1 week'</span><span style="color: #007700">)) .</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> <div class="example-contents"><p>The above example will output something similar to:</p></div> <div class="example-contents screen"> <div class="cdata"><pre> Now: 2005-03-30 Next Week: 2005-04-06 Next Week: 2005-04-06 </pre></div> </div> </div> </p> </div> <div class="refsect1 notes" id="refsect1-function.time-notes"> <h3 class="title">Notes</h3> <div class="tip"><strong class="tip">Tip</strong> <p class="para"> Timestamp of the start of the request is available in <var class="varname"><var class="varname"><a href="reserved.variables.server.html" class="classname">$_SERVER['REQUEST_TIME']</a></var></var> since PHP 5.1. </p> </div> </div> <div class="refsect1 seealso" id="refsect1-function.time-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.date.html" class="function" rel="rdfs-seeAlso">date()</a> - Format a local time/date</span></li> <li class="member"> <span class="function"><a href="function.microtime.html" class="function" rel="rdfs-seeAlso">microtime()</a> - Return current Unix timestamp with microseconds</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.strtotime.html">strtotime</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.timezone-abbreviations-list.html">timezone_abbreviations_list</a></div> <div class="up"><a href="ref.datetime.html">Date/Time Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>