Location: PHPKode > scripts > SA PHP Framework > sa/doc/html/shared_8make__timestamp_8php-source.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>SA PHP Application Framework: public_html/sa-v_0_3/lib/Smarty-2.6.14/libs/plugins/shared.make_timestamp.php Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.6 -->
<div class="tabs">
  <ul>
    <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
    <li><a href="namespaces.html"><span>Namespaces</span></a></li>
    <li><a href="classes.html"><span>Classes</span></a></li>
    <li id="current"><a href="files.html"><span>Files</span></a></li>
  </ul></div>
<h1>public_html/sa-v_0_3/lib/Smarty-2.6.14/libs/plugins/shared.make_timestamp.php</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 &lt;?php
<a name="l00017"></a>00017 function smarty_make_timestamp($string)
<a name="l00018"></a>00018 {
<a name="l00019"></a>00019     <span class="keywordflow">if</span>(empty($string)) {
<a name="l00020"></a>00020         <span class="comment">// use "now":</span>
<a name="l00021"></a>00021         $time = time();
<a name="l00022"></a>00022 
<a name="l00023"></a>00023     } elseif (preg_match('/^\d{14}$/', $string)) {
<a name="l00024"></a>00024         <span class="comment">// it is mysql timestamp format of YYYYMMDDHHMMSS?            </span>
<a name="l00025"></a>00025         $time = mktime(substr($string, 8, 2),substr($string, 10, 2),substr($string, 12, 2),
<a name="l00026"></a>00026                        substr($string, 4, 2),substr($string, 6, 2),substr($string, 0, 4));
<a name="l00027"></a>00027         
<a name="l00028"></a>00028     } elseif (is_numeric($string)) {
<a name="l00029"></a>00029         <span class="comment">// it is a numeric string, we handle it as timestamp</span>
<a name="l00030"></a>00030         $time = (int)$string;
<a name="l00031"></a>00031         
<a name="l00032"></a>00032     } <span class="keywordflow">else</span> {
<a name="l00033"></a>00033         <span class="comment">// strtotime should handle it</span>
<a name="l00034"></a>00034         $time = strtotime($string);
<a name="l00035"></a>00035         <span class="keywordflow">if</span> ($time == -1 || $time === <span class="keyword">false</span>) {
<a name="l00036"></a>00036             <span class="comment">// strtotime() was not able to parse $string, use "now":</span>
<a name="l00037"></a>00037             $time = time();
<a name="l00038"></a>00038         }
<a name="l00039"></a>00039     }
<a name="l00040"></a>00040     <span class="keywordflow">return</span> $time;
<a name="l00041"></a>00041 
<a name="l00042"></a>00042 }
<a name="l00043"></a>00043 
<a name="l00044"></a>00044 <span class="comment">/* vim: set expandtab: */</span>
<a name="l00045"></a>00045 
<a name="l00046"></a>00046 ?&gt;
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Jun 18 17:46:26 2006 for SA PHP Application Framework by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>
</body>
</html>
Return current item: SA PHP Framework