本文整理汇总了PHP中smarty_make_timestamp函数的典型用法代码示例。如果您正苦于以下问题:PHP smarty_make_timestamp函数的具体用法?PHP smarty_make_timestamp怎么用?PHP smarty_make_timestamp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了smarty_make_timestamp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_modifier_date_format
/**
* Smarty date_format modifier plugin.
*
* Type: modifier<br>
* Name: date_format<br>
* Purpose: format datestamps via strftime<br>
* Input:<br>
* - string: input date string
* - format: strftime format for output
* - default_date: default date if $string is empty
*
* @param string $string input
* @param string $format type of the format
* @param string $default_date default date value
*
* @link http://smarty.php.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual)
* @uses smarty_make_timestamp()
*
* @return string|void
*/
function smarty_modifier_date_format($string, $format = SMARTY_RESOURCE_DATE_FORMAT, $default_date = '', $formatter = 'auto')
{
/**
* Include the {@link shared.make_timestamp.php} plugin
*/
require_once SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php';
if ($string != '') {
$timestamp = smarty_make_timestamp($string);
} elseif ($default_date != '') {
$timestamp = smarty_make_timestamp($default_date);
} else {
return '';
}
if ($formatter == 'strftime' || $formatter == 'auto' && strpos($format, '%') !== false) {
if (DS == '\\') {
$_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T');
$_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S');
if (strpos($format, '%e') !== false) {
$_win_from[] = '%e';
$_win_to[] = sprintf('%\' 2d', date('j', $timestamp));
}
if (strpos($format, '%l') !== false) {
$_win_from[] = '%l';
$_win_to[] = sprintf('%\' 2d', date('h', $timestamp));
}
$format = str_replace($_win_from, $_win_to, $format);
}
return strftime($format, $timestamp);
} else {
return date($format, $timestamp);
}
}
示例2: smarty_modifier_date_format
/**
* Smarty date_format modifier plugin
* Type: modifier<br>
* Name: date_format<br>
* Purpose: format datestamps via strftime<br>
* Input:<br>
* - string: input date string
* - format: strftime format for output
* - default_date: default date if $string is empty
* @link http://www.smarty.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @param string $string input date string
* @param string $format strftime format for output
* @param string $default_date default date if $string is empty
* @param string $formatter either 'strftime' or 'auto'
* @return string |void
* @uses smarty_make_timestamp()
*/
function smarty_modifier_date_format($string, $format = NULL, $default_date = '', $formatter = 'auto')
{
if ($format === NULL) {
$format = Smarty::$_DATE_FORMAT;
}
/**
* require_once the {@link shared.make_timestamp.php} plugin
*/
require_once SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php';
if ($string != '' && $string != '0000-00-00' && $string != '0000-00-00 00:00:00') {
$timestamp = smarty_make_timestamp($string);
} elseif ($default_date != '') {
$timestamp = smarty_make_timestamp($default_date);
} else {
return;
}
if ($formatter == 'strftime' || $formatter == 'auto' && strpos($format, '%') !== FALSE) {
if (DS == '\\') {
$_win_from = ['%D', '%h', '%n', '%r', '%R', '%t', '%T'];
$_win_to = ['%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S'];
if (strpos($format, '%e') !== FALSE) {
$_win_from[] = '%e';
$_win_to[] = sprintf('%\' 2d', date('j', $timestamp));
}
if (strpos($format, '%l') !== FALSE) {
$_win_from[] = '%l';
$_win_to[] = sprintf('%\' 2d', date('h', $timestamp));
}
$format = str_replace($_win_from, $_win_to, $format);
}
return strftime($format, $timestamp);
} else {
return date($format, $timestamp);
}
}
示例3: smarty_modifier_date_format
/**
* Smarty date_format modifier plugin
*
* Type: modifier<br>
* Name: date_format<br>
* Purpose: format datestamps via strftime<br>
* Input:<br>
* - string: input date string
* - format: strftime format for output
* - default_date: default date if $string is empty
* @link http://smarty.php.net/manual/en/language.modifier.date.format.php
* date_format (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @param string
* @param string
* @return string|void
* @uses smarty_make_timestamp()
*/
function smarty_modifier_date_format($string, $format = NULL, $default_date = '')
{
if (!$format) {
$format = config('date_format');
return date($format, strtotime($string));
}
if ($string != '') {
$timestamp = smarty_make_timestamp($string);
} elseif ($default_date != '') {
$timestamp = smarty_make_timestamp($default_date);
} else {
return;
}
if (DIRECTORY_SEPARATOR == '\\') {
$_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T');
$_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S');
if (strpos($format, '%e') !== false) {
$_win_from[] = '%e';
$_win_to[] = sprintf('%\' 2d', date('j', $timestamp));
}
if (strpos($format, '%l') !== false) {
$_win_from[] = '%l';
$_win_to[] = sprintf('%\' 2d', date('h', $timestamp));
}
$format = str_replace($_win_from, $_win_to, $format);
}
return strftime($format, $timestamp);
}
示例4: smarty_modifier_zengo_date_long
function smarty_modifier_zengo_date_long($string, $formatter = 'auto')
{
$format = '%d %b, %Y %H:%M';
/**
* Include the {@link shared.make_timestamp.php} plugin
*/
require_once SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php';
if ($string != '' && $string != '0000-00-00' && $string != '0000-00-00 00:00:00') {
$timestamp = smarty_make_timestamp($string);
} else {
return;
}
if ($formatter == 'strftime' || $formatter == 'auto' && strpos($format, '%') !== false) {
if (DS == '\\') {
$_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T');
$_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S');
if (strpos($format, '%e') !== false) {
$_win_from[] = '%e';
$_win_to[] = sprintf('%\' 2d', date('j', $timestamp));
}
if (strpos($format, '%l') !== false) {
$_win_from[] = '%l';
$_win_to[] = sprintf('%\' 2d', date('h', $timestamp));
}
$format = str_replace($_win_from, $_win_to, $format);
}
return strftime($format, $timestamp);
} else {
return date($format, $timestamp);
}
}
示例5: smarty_modifier_date_format_daily
/**
* Smarty date_format modifier plugin
*
* Type: modifier<br>
* Name: date_format<br>
* Purpose: format datestamps via strftime<br>
* Input:<br>
* - string: input date string
* - format: strftime format for output
* - default_date: default date if $string is empty
* @link http://smarty.php.net/manual/en/language.modifier.date.format.php
* date_format (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @param string
* @param string
* @return string|void
* @uses smarty_make_timestamp()
*/
function smarty_modifier_date_format_daily($string, $format = '%b %e, %Y', $default_date = '')
{
global $THEME_CURRENT_DAY;
if ($string != '') {
$timestamp = smarty_make_timestamp($string);
} elseif ($default_date != '') {
$timestamp = smarty_make_timestamp($default_date);
} else {
return;
}
if (DIRECTORY_SEPARATOR == '\\') {
$_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T');
$_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S');
if (strpos($format, '%e') !== false) {
$_win_from[] = '%e';
$_win_to[] = sprintf('%\' 2d', date('j', $timestamp));
}
if (strpos($format, '%l') !== false) {
$_win_from[] = '%l';
$_win_to[] = sprintf('%\' 2d', date('h', $timestamp));
}
$format = str_replace($_win_from, $_win_to, $format);
}
$current_day = strftime($format, $timestamp);
if (!isset($THEME_CURRENT_DAY) || $THEME_CURRENT_DAY != $current_day) {
$THEME_CURRENT_DAY = $current_day;
return $current_day;
}
return '';
}
示例6: smarty_modifier_date_format
/**
* Smarty date_format modifier plugin
*
* Type: modifier<br>
* Name: date_format<br>
* Purpose: format datestamps via strftime<br>
* Input:<br>
* - string: input date string
* - format: strftime format for output
* - default_date: default date if $string is empty
* @link http://smarty.php.net/manual/en/language.modifier.date.format.php
* date_format (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @param string
* @param string
* @return string|void
* @uses smarty_make_timestamp()
*/
function smarty_modifier_date_format($string, $format = '%b %e, %Y', $default_date = '')
{
if (substr(PHP_OS, 0, 3) == 'WIN') {
$_win_from = array('%e', '%T', '%D');
$_win_to = array('%#d', '%H:%M:%S', '%m/%d/%y');
$format = str_replace($_win_from, $_win_to, $format);
}
$arrTemp = array('年', '月', '日', '时', '分', '秒', '時');
foreach ($arrTemp as $v) {
if (strpos($format, $v)) {
$strFormat = str_replace('%', '', $format);
}
}
if ($string != '') {
if (!empty($strFormat)) {
return date($strFormat, smarty_make_timestamp($string));
} else {
return strftime($format, smarty_make_timestamp($string));
}
} elseif (isset($default_date) && $default_date != '') {
if (!empty($strFormat)) {
return date($strFormat, smarty_make_timestamp($default_date));
} else {
return strftime($format, smarty_make_timestamp($default_date));
}
} else {
return;
}
}
示例7: smarty_modifier_prettydate
/**
* Use words instead of dates where it makes sense (today, tomorrow, yesterday).
*
* @package FeM\sPof\template\smartyPlugins
* @author dangerground
* @since 1.0
*
* @api
*
* @param string $string
* @param string $default_date (optional)
* @param bool $time (optional)
*
* @return string
*/
function smarty_modifier_prettydate($string, $default_date = '', $time = true)
{
require_once SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php';
if ($string != '') {
$timestamp = smarty_make_timestamp($string);
} elseif ($default_date != '') {
$timestamp = smarty_make_timestamp($default_date);
} else {
return '';
}
// prepare time
$pdate = date('Ymd', $timestamp);
if ($pdate == date('Ymd')) {
// Today
return '<strong>' . _s('Heute') . '</strong>' . ($time ? ', ' . date('H:i', $timestamp) : '');
} elseif ($pdate == date('Ymd', strtotime('+1 day'))) {
// Tomorrow
return _s('Morgen') . ($time ? ', ' . date('H:i', $timestamp) : '');
} elseif ($pdate == date('Ymd', strtotime('-1 day'))) {
// Yesterday
return _s('Gestern') . ($time ? ', ' . date('H:i', $timestamp) : '');
} else {
// any other day
return date('d.m.Y' . ($time ? ' H:i' : ''), $timestamp);
}
}
示例8: smarty_modifier_date_format
/**
* Smarty date_format modifier plugin
*
* Type: modifier<br>
* Name: date_format<br>
* Purpose: format datestamps via strftime<br>
* Input:<br>
* - string: input date string
* - format: strftime format for output
* - default_date: default date if $string is empty
*
* @link http://www.smarty.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @param string $string input date string
* @param string $format strftime format for output
* @param string $default_date default date if $string is empty
* @param string $formatter either 'strftime' or 'auto'
* @return string |void
* @uses smarty_make_timestamp()
*/
function smarty_modifier_date_format($string, $format = null, $default_date = '', $formatter = 'auto')
{
if ($format === null) {
$format = \Box\Brainy\Brainy::$_DATE_FORMAT;
}
/**
* Include the {@link shared.make_timestamp.php} plugin
*/
include_once SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php';
if ($string != '' && $string != '0000-00-00' && $string != '0000-00-00 00:00:00') {
$timestamp = smarty_make_timestamp($string);
} elseif ($default_date != '') {
$timestamp = smarty_make_timestamp($default_date);
} else {
return;
}
if ($formatter == 'strftime' || $formatter == 'auto' && strpos($format, '%') !== false) {
if (DIRECTORY_SEPARATOR == '\\') {
$_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T');
$_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S');
if (strpos($format, '%e') !== false) {
$_win_from[] = '%e';
$_win_to[] = sprintf('%\' 2d', date('j', $timestamp));
}
if (strpos($format, '%l') !== false) {
$_win_from[] = '%l';
$_win_to[] = sprintf('%\' 2d', date('h', $timestamp));
}
$format = str_replace($_win_from, $_win_to, $format);
}
return strftime($format, $timestamp);
} else {
return date($format, $timestamp);
}
}
示例9: smarty_modifier_date_time_format
/**
* Smarty date_time_format modifier plugin
*
* Type: modifier<br>
* Name: date_time_format<br>
* Purpose: format datestamps via strftime<br>
* Input:<br>
* - string: input date string
* - format: strftime format for output
* - mode: XXX
* - default_date: default date if $string is empty
* @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @param string
* @param string
* @return string|void
* @uses smarty_make_timestamp()
*/
function smarty_modifier_date_time_format($string, $format = '%b %e, %Y', $mode = 'all', $default_date = '')
{
if ($string != '') {
$timestamp = smarty_make_timestamp($string);
} elseif ($default_date != '') {
$timestamp = smarty_make_timestamp($default_date);
} else {
return;
}
if (DIRECTORY_SEPARATOR == '\\') {
$_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T');
$_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S');
if (strpos($format, '%e') !== false) {
$_win_from[] = '%e';
$_win_to[] = sprintf('%\' 2d', date('j', $timestamp));
}
if (strpos($format, '%l') !== false) {
$_win_from[] = '%l';
$_win_to[] = sprintf('%\' 2d', date('h', $timestamp));
}
$format = str_replace($_win_from, $_win_to, $format);
}
// 仅显示日期
if ($mode == 'date') {
$format = array_shift(explode(' ', $format, 2));
// 仅显示时间
} elseif ($mode == 'time') {
$format = array_pop(explode(' ', $format, 2));
}
return strftime($format, $timestamp);
}
示例10: smarty_modifier_timestamp
function smarty_modifier_timestamp($string)
{
require_once SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php';
if ($string != '') {
$timestamp = smarty_make_timestamp($string);
}
return $timestamp;
}
示例11: smarty_modifier_phpdate_format
/**
* Smarty phpdate_format modifier plugin
*
* Type: modifier<br>
* Name: date_format<br>
* Purpose: format datestamps via date()<br>
* Input:<br>
* - string: input date string
* - format: strftime format for output
* - default_date: default date if $string is empty
* @link http://smarty.php.net/manual/en/language.modifier.date.format.php
* date_format (Smarty online manual)
* @param string
* @param string
* @param string
* @return string|void
* @uses smarty_make_timestamp()
*/
function smarty_modifier_phpdate_format($string, $format = "Y/m/d H:i:s", $default_date = null)
{
/* if (substr(PHP_OS,0,3) == 'WIN') {
$_win_from = array ('%e', '%T', '%D');
$_win_to = array ('%#d', '%H:%M:%S', '%m/%d/%y');
$format = str_replace($_win_from, $_win_to, $format);
}*/
if (substr($format, 0, 5) == 'DATE_') {
switch ($format) {
case 'DATE_ATOM':
$nformat = DATE_ATOM;
break;
case 'DATE_COOKIE':
$nformat = DATE_COOKIE;
break;
case 'DATE_ISO8601':
$nformat = DATE_ISO8601;
break;
case 'DATE_RFC822':
$nformat = "D, d M y H:i:s O";
break;
//The php constant is not quite right - as the time-zone comes out with invalid values like "UTC"...
//The php constant is not quite right - as the time-zone comes out with invalid values like "UTC"...
case 'DATE_RFC850':
$nformat = DATE_RFC850;
break;
case 'DATE_RFC1036':
$nformat = DATE_RFC1036;
break;
case 'DATE_RFC1123':
$nformat = DATE_RFC1123;
break;
case 'DATE_RFC2822':
$nformat = DATE_RFC2822;
break;
case 'DATE_RFC3339':
$nformat = DATE_RFC3339;
break;
case 'DATE_RSS':
$nformat = "D, d M Y H:i:s O";
break;
//as rfc822 ...
//as rfc822 ...
case 'DATE_W3C':
$nformat = DATE_W3C;
break;
}
} else {
$nformat = $format;
}
if ($string != '') {
return date($nformat, smarty_make_timestamp($string));
} elseif (isset($default_date) && $default_date != '') {
return date($nformat, smarty_make_timestamp($default_date));
} else {
return;
}
}
示例12: smarty_modifier_date_format
/**
* Smarty date_format modifier plugin
*
* Type: modifier<br>
* Name: date_format<br>
* Purpose: format datestamps via strftime<br>
* Input:<br>
* - string: input date string
* - format: strftime format for output
* - default_date: default date if $string is empty
* @link http://smarty.php.net/manual/en/language.modifier.date.format.php
* date_format (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @param string
* @param string
* @return string|void
* @uses smarty_make_timestamp()
*/
function smarty_modifier_date_format($string, $format = "M n, Y", $default_date = null)
{
if (!empty($string)) {
return date($format, smarty_make_timestamp($string));
} elseif (isset($default_date) && $default_date != '') {
return date($format, smarty_make_timestamp($default_date));
} else {
return;
}
}
示例13: smarty_modifier_date_format
function smarty_modifier_date_format($string, $format = "%b %e, %Y", $default_date = null)
{
if ($string != '') {
return strftime($format, smarty_make_timestamp($string));
} elseif (isset($default_date) && $default_date != '') {
return strftime($format, smarty_make_timestamp($default_date));
} else {
return;
}
}
示例14: smarty_modifier_camp_date_format
/**
* Campsite camp_date_format modifier plugin
*
* Type: modifier
* Name: camp_date_format
* Purpose: format datestamps via MySQL date and time functions
*
* @param string
* $p_unixtime the date in unixtime format from $smarty.now
* @param string
* $p_format the date format wanted
*
* @return
* string the formatted date
* null in case a non-valid format was passed
*/
function smarty_modifier_camp_date_format($p_unixtime, $p_format = null, $p_onlyEnglish = false)
{
static $attributes = array('year'=>'%Y', 'mon'=>'%c', 'mday'=>'%e', 'yday'=>'%j',
'wday'=>'%w', 'hour'=>'%H', 'min'=>'%i', 'sec'=>'%S',
'mon_name'=>'%M', 'wday_name'=>'%W');
static $specifiersMap = array('%h'=>'%I', '%i'=>'%M', '%s'=>'%S');
static $conversionMap = array('%M'=>'__month_name__', '%W'=>'__weekday_name__',
'%c'=>'__month__', '%e'=>'__day_of_the_month__',
'%D'=>'__day_of_the_month_suffix__', '%l'=>'__hour_12_clock__');
static $numberSuffix = array(0=>'th', 1=>'st', 2=>'nd', 3=>'rd', 4=>'th', 5=>'th', 6=>'th',
7=>'th', 8=>'th', 9=>'th');
if (array_key_exists(trim(strtolower($p_format)), $attributes)) {
$p_format = $attributes[trim(strtolower($p_format))];
}
// gets the context variable
$campsite = CampTemplate::singleton()->get_template_vars('gimme');
// makes sure $p_unixtime is unixtime stamp
$p_unixtime = smarty_make_timestamp($p_unixtime);
if (is_null($p_format) || empty($p_format)) {
return strftime('%D %T', $p_unixtime);
}
$p_replaceCount = 0;
$p_format = str_replace(array_keys($conversionMap), array_values($conversionMap),
$p_format, $p_replaceCount);
$p_format = str_replace(array_keys($specifiersMap), array_values($specifiersMap), $p_format);
$formattedDate = strftime($p_format, $p_unixtime);
if ($p_replaceCount > 0) {
$languageObj = new Language($campsite->language->number);
if (!$languageObj->exists()) {
$languageObj = new Language(1);
}
$timeArray = getdate($p_unixtime);
$suffixNo = $timeArray['mday'] % 10;
$hour = $timeArray['hours'] % 12;
if ($hour == 0) {
$hour = 12;
}
$replaceValues = array($languageObj->getProperty('Month'.$timeArray['mon']),
$languageObj->getProperty('WDay'.(1+$timeArray['wday'])),
$timeArray['mon'],
$timeArray['mday'],
$timeArray['mday'].$numberSuffix[$suffixNo],
$hour);
$formattedDate = str_replace(array_values($conversionMap), $replaceValues, $formattedDate);
}
return $formattedDate;
} // fn smarty_modifier_camp_date_format
示例15: smarty_modifier_idate
function smarty_modifier_idate($string, $format = 'Y-m-d H:i:s', $default_date = '')
{
if ($string != '') {
$timestamp = smarty_make_timestamp($string);
} elseif ($default_date != '') {
$timestamp = smarty_make_timestamp($default_date);
} else {
return;
}
return Core_Fun::date($format, $timestamp);
}