<!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>Get Unix timestamp for a GMT date</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.gmdate.html">gmdate</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.gmstrftime.html">gmstrftime</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.gmmktime" class="refentry"> <div class="refnamediv"> <h1 class="refname">gmmktime</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">gmmktime</span> — <span class="dc-title">Get Unix timestamp for a GMT date</span></p> </div> <div class="refsect1 description" id="refsect1-function.gmmktime-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">int</span> <span class="methodname"><strong>gmmktime</strong></span> ([ <span class="methodparam"><span class="type">int</span> <code class="parameter">$hour</code><span class="initializer"> = gmdate("H")</span></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$minute</code><span class="initializer"> = gmdate("i")</span></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$second</code><span class="initializer"> = gmdate("s")</span></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$month</code><span class="initializer"> = gmdate("n")</span></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$day</code><span class="initializer"> = gmdate("j")</span></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$year</code><span class="initializer"> = gmdate("Y")</span></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$is_dst</code><span class="initializer"> = -1</span></span> ]]]]]]] )</div> <p class="para rdfs-comment"> Identical to <span class="function"><a href="function.mktime.html" class="function">mktime()</a></span> except the passed parameters represents a GMT date. <span class="function"><strong>gmmktime()</strong></span> internally uses <span class="function"><a href="function.mktime.html" class="function">mktime()</a></span> so only times valid in derived local time can be used. </p> <p class="para"> Like <span class="function"><a href="function.mktime.html" class="function">mktime()</a></span>, arguments may be left out in order from right to left, with any omitted arguments being set to the current corresponding GMT value. </p> </div> <div class="refsect1 parameters" id="refsect1-function.gmmktime-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">hour</code></em></span> <dd> <p class="para"> The number of the hour relative to the start of the day determined by <em><code class="parameter">month</code></em>, <em><code class="parameter">day</code></em> and <em><code class="parameter">year</code></em>. Negative values reference the hour before midnight of the day in question. Values greater than 23 reference the appropriate hour in the following day(s). </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">minute</code></em></span> <dd> <p class="para"> The number of the minute relative to the start of the <em><code class="parameter">hour</code></em>. Negative values reference the minute in the previous hour. Values greater than 59 reference the appropriate minute in the following hour(s). </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">second</code></em></span> <dd> <p class="para"> The number of seconds relative to the start of the <em><code class="parameter">minute</code></em>. Negative values reference the second in the previous minute. Values greater than 59 reference the appropriate second in the following minute(s). </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">month</code></em></span> <dd> <p class="para"> The number of the month relative to the end of the previous year. Values 1 to 12 reference the normal calendar months of the year in question. Values less than 1 (including negative values) reference the months in the previous year in reverse order, so 0 is December, -1 is November, etc. Values greater than 12 reference the appropriate month in the following year(s). </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">day</code></em></span> <dd> <p class="para"> The number of the day relative to the end of the previous month. Values 1 to 28, 29, 30 or 31 (depending upon the month) reference the normal days in the relevant month. Values less than 1 (including negative values) reference the days in the previous month, so 0 is the last day of the previous month, -1 is the day before that, etc. Values greater than the number of days in the relevant month reference the appropriate day in the following month(s). </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">year</code></em></span> <dd> <p class="para"> The year </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">is_dst</code></em></span> <dd> <p class="para"> Parameters always represent a GMT date so <em><code class="parameter">is_dst</code></em> doesn't influence the result. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.gmmktime-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns a <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span> Unix timestamp. </p> </div> <div class="refsect1 changelog" id="refsect1-function.gmmktime-changelog"> <h3 class="title">Changelog</h3> <p class="para"> <table class="doctable informaltable"> <thead> <tr> <th>Version</th> <th>Description</th> </tr> </thead> <tbody class="tbody"> <tr> <td>5.1.0</td> <td> As of PHP 5.1.0, the <em><code class="parameter">is_dst</code></em> parameter became deprecated. As a result, the new timezone handling features should be used instead. </td> </tr> </tbody> </table> </p> </div> <div class="refsect1 examples" id="refsect1-function.gmmktime-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-2308"> <p><strong>Example #1 <span class="function"><strong>gmmktime()</strong></span> basic example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">// Prints: July 1, 2000 is on a Saturday<br /></span><span style="color: #007700">echo </span><span style="color: #DD0000">"July 1, 2000 is on a " </span><span style="color: #007700">. </span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">"l"</span><span style="color: #007700">, </span><span style="color: #0000BB">gmmktime</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">7</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">2000</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 seealso" id="refsect1-function.gmmktime-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.mktime.html" class="function" rel="rdfs-seeAlso">mktime()</a> - Get Unix timestamp for a date</span></li> <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.time.html" class="function" rel="rdfs-seeAlso">time()</a> - Return current Unix timestamp</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.gmdate.html">gmdate</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.gmstrftime.html">gmstrftime</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>