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


PHP adodb_getdate函数代码示例

本文整理汇总了PHP中adodb_getdate函数的典型用法代码示例。如果您正苦于以下问题:PHP adodb_getdate函数的具体用法?PHP adodb_getdate怎么用?PHP adodb_getdate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: adodb_date_test


//.........这里部分代码省略.........
    }
    if (adodb_year_digit_check(10) != 2010) {
        print "Err 2-digit 2010<br>";
    }
    if (adodb_year_digit_check(20) != 2020) {
        print "Err 2-digit 2020<br>";
    }
    if (adodb_year_digit_check(30) != 2030) {
        print "Err 2-digit 2030<br>";
    }
    if (adodb_year_digit_check(40) != 1940) {
        print "Err 2-digit 1940<br>";
    }
    if (adodb_year_digit_check(50) != 1950) {
        print "Err 2-digit 1950<br>";
    }
    if (adodb_year_digit_check(90) != 1990) {
        print "Err 2-digit 1990<br>";
    }
    // Test string formating
    print "<p>Testing date formating</p>";
    $fmt = '\\d\\a\\t\\e T Y-m-d H:i:s a A d D F g G h H i j l L m M n O \\R\\F\\C2822 r s t U w y Y z Z 2003';
    $s1 = date($fmt, 0);
    $s2 = adodb_date($fmt, 0);
    if ($s1 != $s2) {
        print " date() 0 failed<br>{$s1}<br>{$s2}<br>";
    }
    flush();
    for ($i = 100; --$i > 0;) {
        $ts = 3600.0 * (rand() % 60000 + rand() % 60000) + rand() % 60000;
        $s1 = date($fmt, $ts);
        $s2 = adodb_date($fmt, $ts);
        //print "$s1 <br>$s2 <p>";
        $pos = strcmp($s1, $s2);
        if ($s1 != $s2) {
            for ($j = 0, $k = strlen($s1); $j < $k; $j++) {
                if ($s1[$j] != $s2[$j]) {
                    print substr($s1, $j) . ' ';
                    break;
                }
            }
            print "<b>Error date(): {$ts}<br><pre> \n&nbsp; \"{$s1}\" (date len=" . strlen($s1) . ")\n&nbsp; \"{$s2}\" (adodb_date len=" . strlen($s2) . ")</b></pre><br>";
            $fail = true;
        }
        $a1 = getdate($ts);
        $a2 = adodb_getdate($ts);
        $rez = array_diff($a1, $a2);
        if (sizeof($rez) > 0) {
            print "<b>Error getdate() {$ts}</b><br>";
            print_r($a1);
            print "<br>";
            print_r($a2);
            print "<p>";
            $fail = true;
        }
    }
    // Test generation of dates outside 1901-2038
    print "<p>Testing random dates between 100 and 4000</p>";
    adodb_date_test_date(100, 1);
    for ($i = 100; --$i >= 0;) {
        $y1 = 100 + rand(0, 1970 - 100);
        $m = rand(1, 12);
        adodb_date_test_date($y1, $m);
        $y1 = 3000 - rand(0, 3000 - 1970);
        adodb_date_test_date($y1, $m);
    }
    print '<p>';
    $start = 1960 + rand(0, 10);
    $yrs = 12;
    $i = 365.25 * 86400 * ($start - 1970);
    $offset = 36000 + rand(10000, 60000);
    $max = 365 * $yrs * 86400;
    $lastyear = 0;
    // we generate a timestamp, convert it to a date, and convert it back to a timestamp
    // and check if the roundtrip broke the original timestamp value.
    print "Testing {$start} to " . ($start + $yrs) . ", or {$max} seconds, offset={$offset}: ";
    $cnt = 0;
    for ($max += $i; $i < $max; $i += $offset) {
        $ret = adodb_date('m,d,Y,H,i,s', $i);
        $arr = explode(',', $ret);
        if ($lastyear != $arr[2]) {
            $lastyear = $arr[2];
            print " {$lastyear} ";
            flush();
        }
        $newi = adodb_mktime($arr[3], $arr[4], $arr[5], $arr[0], $arr[1], $arr[2]);
        if ($i != $newi) {
            print "Error at {$i}, adodb_mktime returned {$newi} ({$ret})";
            $fail = true;
            break;
        }
        $cnt += 1;
    }
    echo "Tested {$cnt} dates<br>";
    if (!$fail) {
        print "<p>Passed !</p>";
    } else {
        print "<p><b>Failed</b> :-(</p>";
    }
}
开发者ID:dasatti,项目名称:dashboard,代码行数:101,代码来源:adodb-time.inc.php

示例2: cred_pe_render_meta_box_content

 /**
  * Render Meta Box content.
  *
  * @param WP_Post $post The post object.
  * */
 public function cred_pe_render_meta_box_content($post)
 {
     $post_expiration_time = get_post_meta($post->ID, $this->_post_expiration_time_field, true);
     if (empty($post_expiration_time)) {
         $values = array('date' => '', 'hours' => 0, 'minutes' => 0);
     } else {
         $values = adodb_getdate($post_expiration_time);
         $values['minutes'] = floor($values['minutes'] / 15) * 15;
         $date_format = preg_replace('/(\\s)*[:@aAghGHisTcr]+(\\s)*/', '', get_option('date_format'));
         $date_format = preg_replace('/[,-\\/\\s]+$/', '', $date_format);
         $values['date'] = adodb_date($date_format, $post_expiration_time);
     }
     $post_expiration_action = get_post_meta($post->ID, $this->_post_expiration_action_field, true);
     if (!isset($post_expiration_action['post_status'])) {
         $post_expiration_action['post_status'] = '';
     }
     echo CRED_Loader::tpl('pe_post_meta_box', array('cred_post_expiration' => $this, 'post_expiration_time' => $post_expiration_time, 'post_expiration_action' => $post_expiration_action, 'values' => $values, 'post_expiration_slug' => $this->_post_expiration_slug, 'time_field_name' => $this->_post_expiration_time_field, 'action_field_name' => $this->_post_expiration_action_field));
 }
开发者ID:rebeccayshen,项目名称:kitlist,代码行数:23,代码来源:CredPostExpiration.php

示例3:

{
    $newparam=$param;   // newparam is for birthday links
    $newparam=preg_replace('/action=show_month&?/i','',$newparam);
    $newparam=preg_replace('/action=show_week&?/i','',$newparam);
    $newparam=preg_replace('/day=[0-9][0-9]&?/i','',$newparam);
    $newparam=preg_replace('/month=[0-9][0-9]&?/i','',$newparam);
    $newparam=preg_replace('/year=[0-9]+&?/i','',$newparam);
    // Code to show just one day
    $style='cal_current_month';
    $today=0;
    $todayarray=dol_getdate($now,'fast');
    if ($todayarray['mday']==$day && $todayarray['mon']==$month && $todayarray['year']==$year) $today=1;
    if ($today) $style='cal_today';

    $timestamp=dol_mktime(12,0,0,$month,$day,$year);
    $arraytimestamp=adodb_getdate(dol_mktime(12,0,0,$month,$day,$year));
    echo '<table width="100%" class="nocellnopadd">';
    echo ' <tr class="liste_titre">';
    echo '  <td align="center">'.$langs->trans("Day".$arraytimestamp['wday'])."</td>\n";
    echo " </tr>\n";
    echo " <tr>\n";
    echo '  <td class="'.$style.'" width="14%" valign="top"  nowrap="nowrap">';
    $maxnbofchar=80;
    show_day_events ($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300);
    echo "</td>\n";
    echo " </tr>\n";
    echo '</table>';
}


$db->close();
开发者ID:remyyounes,项目名称:dolibarr,代码行数:31,代码来源:index.php

示例4: GetDateTime

 function GetDateTime($ts)
 {
     if ($this->UseAdodbTime) {
         return adodb_getdate($ts);
     } else {
         return getdate($ts);
     }
 }
开发者ID:Ombogo,项目名称:new_api_chat,代码行数:8,代码来源:ganttfn.php

示例5: formatDate

 function formatDate($value)
 {
     if (!is_numeric($value)) {
         $v = str2date($value);
         if (!is_null($v)) {
             $value = $v;
         } else {
             return $this->stdFormat($value);
         }
     }
     if (is_numeric($value)) {
         $dateParts = adodb_getdate($value);
         //speed: adodb_getdate is slow!!!
         $year = $dateParts['year'];
         $month = $dateParts['mon'];
         $day = $dateParts['mday'];
         $hour = $dateParts['hours'];
         $min = $dateParts['minutes'];
         $secs = $dateParts['seconds'];
         $dow = $dateParts['wday'];
     }
     $_day_power = 86400;
     $_hour_power = 3600;
     $_min_power = 60;
     //cannot replace Epoch by constant, because value of adodb_mktime depends on time zone
     //but we compute it only once ....
     static $_MicrosoftEpoch;
     //speed: cache $epoch (1.5sec)
     if (!$_MicrosoftEpoch) {
         $_MicrosoftEpoch = adodb_mktime(0, 0, 0, 12, 30, 1899);
     }
     if (sizeof($this->formatParts) == 1) {
         $fmt = $this->formatParts[0];
     } elseif ($value == $_MicrosoftEpoch) {
         if ($this->formatParts[2]) {
             $fmt = $this->formatParts[2];
         } else {
             $fmt = $this->formatParts[0];
         }
     } elseif (is_null($value)) {
         $fmt = $this->formatParts[3];
     } else {
         $fmt = $this->formatParts[0];
     }
     $res = '';
     if (!isset($fmt)) {
         if (is_null($value)) {
             return '';
         } else {
             if ($year == 1899 && $month == 12 && ($day = 30)) {
                 if ($hour == 0 && $min == 0 && $sec == 0) {
                     return null;
                 } else {
                     return format($value, 'long time');
                 }
             } else {
                 if ($hour == 0 && $min == 0 && $sec == 0) {
                     return format($value, 'short date');
                 } else {
                     return format($value, 'general date');
                 }
             }
         }
     }
     foreach ($fmt as $fmtItem) {
         switch ($fmtItem['token']) {
             case $this->STRING:
                 $res .= $fmtItem['value'];
                 break;
             case 'd':
                 $res .= $day;
                 $this->OnDayFormat();
                 break;
             case 'dd':
                 $res .= $this->twoDigits($day);
                 $this->OnDayFormat();
                 break;
             case 'ddd':
                 $res .= strftime('%a', $_day_power * (3 + $dow));
                 break;
             case 'dddd':
                 $res .= strftime('%A', $_day_power * (3 + $dow));
                 break;
             case 'ddddd':
                 $res .= format($value, 'short date');
                 break;
             case 'dddddd':
                 $res .= format($value, 'long date');
                 break;
             case 'm':
                 $res .= $month;
                 $this->OnMonthFormat();
                 break;
             case 'mm':
                 $res .= $this->twoDigits($month);
                 $this->OnMonthFormat();
                 break;
             case 'mmm':
                 $res .= strftime('%b', mktime(0, 0, 0, $month, 2, 1971));
                 $this->OnMonthFormat();
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:amber-svn,代码行数:101,代码来源:basic.php

示例6: dol_getdate

/**
 *	Return an array with date info
 *  PHP getdate is restricted to the years 1901-2038 on Unix and 1970-2038 on Windows.
 *	@param		timestamp		Timestamp
 *	@param		fast			Fast mode
 *	@return		array			Array of informations
 *				If no fast mode:
 *				'seconds' => $secs,
 *				'minutes' => $min,
 *				'hours' => $hour,
 *				'mday' => $day,
 *				'wday' => $dow,
 *				'mon' => $month,
 *				'year' => $year,
 *				'yday' => floor($secsInYear/$_day_power),
 *				'weekday' => gmdate('l',$_day_power*(3+$dow)),
 *				'month' => gmdate('F',mktime(0,0,0,$month,2,1971)),
 *				If fast mode:
 *				'seconds' => $secs,
 *				'minutes' => $min,
 *				'hours' => $hour,
 *				'mday' => $day,
 *				'mon' => $month,
 *				'year' => $year,
 *				'yday' => floor($secsInYear/$_day_power),
 *				'leap' => $leaf,
 *				'ndays' => $ndays
 */
function dol_getdate($timestamp, $fast = false)
{
    $usealternatemethod = false;
    if ($timestamp <= 0) {
        $usealternatemethod = true;
    }
    // <= 1970
    if ($timestamp >= 2145913200) {
        $usealternatemethod = true;
    }
    // >= 2038
    if ($usealternatemethod) {
        $arrayinfo = adodb_getdate($timestamp, $fast);
    } else {
        $arrayinfo = getdate($timestamp);
    }
    return $arrayinfo;
}
开发者ID:netors,项目名称:dolibarr,代码行数:46,代码来源:functions.lib.php

示例7: getYear

 function getYear()
 {
     $array = adodb_getdate($this->timestamp);
     return $array['year'];
 }
开发者ID:jeromecc,项目名称:tuv2,代码行数:5,代码来源:clDate.php

示例8: dol_getdate

/**
 *	Return an array with locale date info.
 *  PHP getdate is restricted to the years 1901-2038 on Unix and 1970-2038 on Windows
 *  WARNING: This function always use PHP server timezone to return locale informations !!!
 *  Usage must be avoid.
 *  FIXME: Replace this with PHP date function and a parameter $gm
 *
 *	@param	int			$timestamp      Timestamp
 *	@param	boolean		$fast           Fast mode
 *	@return	array						Array of informations
 *										If no fast mode:
 *										'seconds' => $secs,
 *										'minutes' => $min,
 *										'hours' => $hour,
 *										'mday' => $day,
 *										'wday' => $dow,		0=sunday, 6=saturday
 *										'mon' => $month,
 *										'year' => $year,
 *										'yday' => floor($secsInYear/$_day_power),
 *										'weekday' => gmdate('l',$_day_power*(3+$dow)),
 *										'month' => gmdate('F',mktime(0,0,0,$month,2,1971)),
 *										If fast mode:
 *										'seconds' => $secs,
 *										'minutes' => $min,
 *										'hours' => $hour,
 *										'mday' => $day,
 *										'mon' => $month,
 *										'year' => $year,
 *										'yday' => floor($secsInYear/$_day_power),
 *										'leap' => $leaf,
 *										'ndays' => $ndays
 * 	@see 								dol_print_date, dol_stringtotime, dol_mktime
 */
function dol_getdate($timestamp, $fast = false)
{
    global $conf;
    $usealternatemethod = false;
    if ($timestamp <= 0) {
        $usealternatemethod = true;
    }
    // <= 1970
    if ($timestamp >= 2145913200) {
        $usealternatemethod = true;
    }
    // >= 2038
    if ($usealternatemethod) {
        $arrayinfo = adodb_getdate($timestamp, $fast);
    } else {
        $arrayinfo = getdate($timestamp);
        /*$startday=isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1;
        		if($startday==1)
        		{
        			if ($arrayinfo["wday"]==0)
        			{
        				$arrayinfo["wday"]=6;
        			}
        			else
        			{
        				$arrayinfo["wday"]=$arrayinfo["wday"]-1;
        			}
        		}*/
    }
    return $arrayinfo;
}
开发者ID:ADDAdev,项目名称:Dolibarr,代码行数:64,代码来源:functions.lib.php

示例9: carl_getdate

/**
 * Alias for adodb_getdate()
 */
function carl_getdate($timestamp = false, $fast = false)
{
    return adodb_getdate($timestamp, $fast);
}
开发者ID:hunter2814,项目名称:reason_package,代码行数:7,代码来源:date_funcs.php

示例10: display

 /**
  * Function display's the date.
  *
  * @param array $record array with date
  * @param string $mode
  *
  * @return string formatted date string
  */
 public function display($record, $mode)
 {
     $value = isset($record[$this->fieldName()]) ? $record[$this->fieldName()] : null;
     if (!is_array($value) || empty($value['month']) || empty($value['day']) || empty($value['year'])) {
         return '';
     }
     $tmp_date = adodb_getdate(adodb_mktime(0, 0, 0, $value['month'], $value['day'], $value['year']));
     if (!empty($tmp_date)) {
         $d = $this->formatDate($tmp_date, $this->m_date_format_view, $this->hasFlag(self::AF_DATE_DISPLAY_DAY));
         if ($mode == 'list') {
             $d = str_replace(' ', '&nbsp;', $d);
         }
         return $d;
     } else {
         return '&nbsp;';
     }
 }
开发者ID:sintattica,项目名称:atk,代码行数:25,代码来源:DateAttribute.php


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