/[cvs]/nfo/php/libs/net.php.smarty/plugins/shared.make_timestamp.php
ViewVC logotype

Annotation of /nfo/php/libs/net.php.smarty/plugins/shared.make_timestamp.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Wed Jun 16 21:58:17 2004 UTC (20 years, 2 months ago) by joko
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +17 -9 lines
updated to smarty-2.6.3

1 cvsjoko 1.1 <?php
2 joko 1.2 /**
3     * Smarty shared plugin
4     * @package Smarty
5     * @subpackage plugins
6     */
7 cvsjoko 1.1
8 joko 1.2
9     /**
10     * Function: smarty_make_timestamp<br>
11     * Purpose: used by other smarty functions to make a timestamp
12     * from a string.
13     * @param string
14     * @return string
15     */
16 cvsjoko 1.1 function smarty_make_timestamp($string)
17     {
18     if(empty($string)) {
19     $string = "now";
20     }
21     $time = strtotime($string);
22     if (is_numeric($time) && $time != -1)
23     return $time;
24    
25     // is mysql timestamp format of YYYYMMDDHHMMSS?
26 joko 1.2 if (preg_match('/^\d{14}$/', $string)) {
27 cvsjoko 1.1 $time = mktime(substr($string,8,2),substr($string,10,2),substr($string,12,2),
28     substr($string,4,2),substr($string,6,2),substr($string,0,4));
29    
30     return $time;
31     }
32    
33     // couldn't recognize it, try to return a time
34     $time = (int) $string;
35     if ($time > 0)
36 joko 1.2 return $time;
37     else
38     return time();
39 cvsjoko 1.1 }
40    
41     /* vim: set expandtab: */
42    
43     ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed