当前位置: 首页>>代码示例>>PHP>>正文


PHP Func::parse_datetime方法代码示例

本文整理汇总了PHP中Func::parse_datetime方法的典型用法代码示例。如果您正苦于以下问题:PHP Func::parse_datetime方法的具体用法?PHP Func::parse_datetime怎么用?PHP Func::parse_datetime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Func的用法示例。


在下文中一共展示了Func::parse_datetime方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: smarty_modifier_dateleft

/**
 * Smarty dateleft modifier plugin
 *
 * Type:     modifier<br>
 * Name:     dateleft<br>
 * Purpose:  dateleft
 * @author battazo
 * @param string
 * @param string
 * @param interger
 * @param interger
 * @param string                   
 * @param string
 */
function smarty_modifier_dateleft($sDatetime, $getTime = false)
{
    //get datetime
    if (!$sDatetime) {
        return false;
    }
    $date = Func::parse_datetime($sDatetime);
    //    function dateDiff($dformat, $endDate, $beginDate)
    //    {
    //        $date_parts1 = explode($dformat, $beginDate);
    //        $date_parts2 = explode($dformat, $endDate);
    //        $start_date  = gregoriantojd($date_parts1[0], $date_parts1[1], $date_parts1[2]);
    //        $end_date    = gregoriantojd($date_parts2[0], $date_parts2[1], $date_parts2[2]);
    //        return $end_date - $start_date;
    //    }
    //    $date1="07/11/2003";
    //    $date2="09/04/2004";
    //    print "If we minus " . $date1 . " from " . $date2 . " we get " . dateDiff("/", $date2, $date1) . ".";
    //    If we minus 07/11/2003 from 09/04/2004 we get 421.
    //$dob="08/12/1975";
    //echo "If you were born on " . $dob . ", then today your age is approximately " .
    //round(dateDiff("/", date("m/d/Y", time()), $dob)/365, 0) . " years.";
    //If you were born on 08/12/1975, then today your age is approximately 30 years.
    smarty_modifier_datespent($sDatetime, $getTime);
}
开发者ID:Sywooch,项目名称:dobox,代码行数:39,代码来源:modifier.dateleft.php

示例2: smarty_modifier_date_format2

/**
 * Smarty date_format2 modifier plugin
 *
 * Type:     modifier<br>
 * Name:     date_format2<br>
 * Purpose:  date_format2
 * @author battazo
 * @param string
 * @param string
 * @param interger
 * @param interger
 * @param string
 * @param string
 */
function smarty_modifier_date_format2($sDatetime, $getTime = false, $bSkipYearIfCurrent = false, $glue1 = ' ', $glue2 = ' в ')
{
    if (!$sDatetime) {
        if (is_string($bSkipYearIfCurrent)) {
            return $bSkipYearIfCurrent;
        }
        return false;
    }
    $res = Func::parse_datetime($sDatetime);
    switch (intval($res['month'])) {
        case '1':
            $res['month'] = 'Января';
            break;
        case '2':
            $res['month'] = 'Февраля';
            break;
        case '3':
            $res['month'] = 'Марта';
            break;
        case '4':
            $res['month'] = 'Апреля';
            break;
        case '5':
            $res['month'] = 'Мая';
            break;
        case '6':
            $res['month'] = 'Июня';
            break;
        case '7':
            $res['month'] = 'Июля';
            break;
        case '8':
            $res['month'] = 'Августа';
            break;
        case '9':
            $res['month'] = 'Сентября';
            break;
        case '10':
            $res['month'] = 'Октября';
            break;
        case '11':
            $res['month'] = 'Ноября';
            break;
        case '12':
            $res['month'] = 'Декабря';
            break;
        default:
            break;
    }
    if ($getTime) {
        return intval($res['day']) . ' ' . $res['month'] . ($bSkipYearIfCurrent === true && date('Y', time()) == $res['year'] ? '' : $glue1 . $res['year']) . (!(int) $res['hour'] && !(int) $res['min'] ? '' : $glue2 . $res['hour'] . ':' . $res['min']);
    } else {
        return intval($res['day']) . ' ' . $res['month'] . ($bSkipYearIfCurrent === true && date('Y', time()) == $res['year'] ? '' : $glue1 . $res['year']);
    }
}
开发者ID:Sywooch,项目名称:dobox,代码行数:69,代码来源:modifier.date_format2.php

示例3: smarty_modifier_datespent

/**
 * Smarty datespent modifier plugin
 *
 * Type:     modifier<br>
 * Name:     datespent<br>
 * Purpose:  datespent
 * @author battazo
 * @param string
 * @param string
 * @param interger
 * @param interger
 * @param string
 * @param string
 */
function smarty_modifier_datespent($sDatetime, $getTime = false)
{
    //get datetime
    if (!$sDatetime) {
        return false;
    }
    $date = Func::parse_datetime($sDatetime);
    //get now datetime
    static $now;
    if (!isset($now)) {
        $now = date('Y,m,d,H,i,s');
    }
    $nowdt = array();
    list($nowdt['year'], $nowdt['month'], $nowdt['day'], $nowdt['hour'], $nowdt['min'], $nowdt['sec']) = explode(',', $now);
    //дата позже текущей
    if ($nowdt['year'] < $date['year']) {
        return '';
    }
    //since
    $since = array();
    foreach ($nowdt as $k => $v) {
        $since[$k] = $nowdt[$k] - $date[$k];
    }
    $tmp = array(0 => array('sec', 60, 'секунда;секунды;секунд'), 1 => array('min', 60, 'минута;минуты;минут'), 2 => array('hour', 24, 'час;часа;часов'), 3 => array('day', 30, 'день;дня;дней'), 4 => array('month', 12, 'месяц;месяца;месяцев'), 5 => array('year', 0, 'год;года;лет'));
    //    if(!function_exists('calcsince'))
    //    {
    //        function calcsince($i, $minus = false)
    //        {
    //            global $tmp, $date, $nowdt, $since;
    //            $key = $tmp[$i][0];
    //            if ($minus) {
    //                --$nowdt[$key];
    //                if ($nowdt[$key] == $date[$key]) {
    //                    $since[$key] = $nowdt[$key] - $date[$key];
    //                }
    //            }
    //            $minus = false;
    //            if ($nowdt[$key] < $date[$key]) {
    //                $since[$key] =  $tmp[$i][1] + $nowdt[$key] - $date[$key];
    //                $minus = true;
    //            }
    //            if(++$i > 5) return;
    //            calcsince($tmp, $date, $nowdt, $since, $i, $minus);
    //        }
    //    }
    //    calcsince(0);
    $minus = false;
    //seconds
    if ($minus) {
        $nowdt['sec']--;
        if ($nowdt['sec'] == $date['sec']) {
            $since['sec'] = $nowdt['sec'] - $date['sec'];
        }
    }
    $minus = false;
    if ($nowdt['sec'] < $date['sec']) {
        $since['sec'] = 60 + $nowdt['sec'] - $date['sec'];
        $minus = true;
    }
    //minutes
    if ($minus) {
        $nowdt['min']--;
        if ($nowdt['min'] == $date['min']) {
            $since['min'] = $nowdt['min'] - $date['min'];
        } else {
            $since['min']--;
        }
    }
    $minus = false;
    if ($nowdt['min'] < $date['min']) {
        $since['min'] = 60 + $nowdt['min'] - $date['min'];
        $minus = true;
    }
    //hours --------------------------------------
    if ($minus) {
        $nowdt['hour']--;
        if ($nowdt['hour'] == $date['hour']) {
            $since['hour'] = $nowdt['hour'] - $date['hour'];
        }
    }
    $minus = false;
    if ($nowdt['hour'] < $date['hour']) {
        $since['hour'] = 24 + $nowdt['hour'] - $date['hour'];
        $minus = true;
    }
    //days ---------------------------------------
//.........这里部分代码省略.........
开发者ID:Sywooch,项目名称:dobox,代码行数:101,代码来源:modifier.datespent.php

示例4: Datetime2dateUSSR

 static function Datetime2dateUSSR($sDatetime = '2007-12-31 00:00:00', $getTime = false)
 {
     if (!$sDatetime) {
         return false;
     }
     $res = Func::parse_datetime($sDatetime);
     if ($getTime) {
         return $res['day'] . '/' . $res['month'] . '/' . $res['year'] . ' ' . $res['hour'] . ':' . $res['min'] . ':' . $res['sec'];
     } else {
         return $res['day'] . '/' . $res['month'] . '/' . $res['year'];
     }
 }
开发者ID:Sywooch,项目名称:dobox,代码行数:12,代码来源:func.php


注:本文中的Func::parse_datetime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。