Zikula_Template_Plugins
[ class tree: Zikula_Template_Plugins ] [ index: Zikula_Template_Plugins ] [ all elements ]

Source for file function.datetime.php

Documentation is available at function.datetime.php

  1. <?php
  2. /**
  3.  * Zikula Application Framework
  4.  *
  5.  * @copyright (c) 2004, Zikula Development Team
  6.  * @link http://www.zikula.org
  7.  * @version $Id: function.datetime.php 24342 2008-06-06 12:03:14Z markwest $
  8.  * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
  9.  * @package Zikula_Template_Plugins
  10.  * @subpackage Functions
  11.  */
  12.  
  13. /**
  14.  * Smarty function to display the current date and time
  15.  *
  16.  * Example
  17.  * <!--[datetime]-->
  18.  *
  19.  * <!--[datetime format="_DATEBRIEF"]-->
  20.  *
  21.  * <!--[datetime format='%b %d, %Y - %I:%M %p']-->
  22.  *
  23.  *  Format:
  24.  * _DATEBRIEF       '%b %d, %Y'
  25.  * _DATELONG        '%A, %B %d, %Y'
  26.  * _DATESTRING      '%A, %B %d @ %H:%M:%S'
  27.  * _DATETIMEBRIEF   '%b %d, %Y - %I:%M %p'
  28.  * _DATETIMELONG    '%A, %B %d, %Y - %I:%M %p'
  29.  *
  30.  * Key:
  31.  * %a - abbreviated weekday name according to the current locale
  32.  * %A = full weekday name according to the current locale
  33.  * %b = abbreviated month name according to the current locale
  34.  * %B = full month name according to the current locale
  35.  * %d = day of the month as a decimal number (range 01 to 31)
  36.  * %D = same as %m/%d/%y
  37.  * %y = year as a decimal number including the century
  38.  * %Y = year as a decimal number without a century (range 00 to 99)
  39.  * %H = hour as a decimal number using a 24-hour clock (range 00 to 23)
  40.  * %I = hour as a decimal number using a 12-hour clock (range 01 to 12)
  41.  * %M = minute as a decimal number
  42.  * %S = second as a decimal number
  43.  * %p = either 'am' or 'pm' according to the given time value, or the corresponding strings for the current locale
  44.  
  45.  * ml_ftime function is defined in modules/NS-languages/api.php in PN 0.7x
  46.  * and in includes/pnLang.php line 450 in PN 0.8
  47.  * http://www.php.net/manual/en/function.strftime.php
  48.  
  49.  * @author       Mark West & Martin Andersen
  50.  * @since        19/10/2003
  51.  * @see          function.datetime.php::smarty_function_datetime()
  52.  * @param        array       $params      All attributes passed to this function from the template
  53.  * @param        object      &$smarty     Reference to the Smarty object
  54.  * @param        string      format       Date and time format
  55.  * @return       string      current date and time
  56.  */
  57. function smarty_function_datetime($params&$smarty)
  58. {
  59.     extract($params);
  60.     unset($params);
  61.  
  62.     // set some defaults
  63.     if (!isset($format)) {
  64.         $format '_DATETIMEBRIEF';
  65.     }
  66.     if (strpos($format'%'!== false// allow the use of conversion specifiers
  67.         return ml_ftime($format(GetUserTime(time())));
  68.     }
  69.     return ml_ftime(constant($format)(GetUserTime(time())));
  70. }

Documentation generated on Fri, 18 Jul 2008 21:45:13 +0200 by phpDocumentor 1.4.1