本文整理匯總了PHP中TimeExpressionParser::getISODateTime方法的典型用法代碼示例。如果您正苦於以下問題:PHP TimeExpressionParser::getISODateTime方法的具體用法?PHP TimeExpressionParser::getISODateTime怎麽用?PHP TimeExpressionParser::getISODateTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類TimeExpressionParser
的用法示例。
在下文中一共展示了TimeExpressionParser::getISODateTime方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: caGetDateRangeForCalendar
/**
* Returns date range for calendar display
*
* @param int $pn_start_timestamp Start of date range, as Unix timestamp
* @param array $pa_options All options supported by TimeExpressionParser::getText() are supported
*
* @return string Localized date range expression
*/
function caGetDateRangeForCalendar($pa_historic_timestamps, $pa_options = null)
{
$o_tep = new TimeExpressionParser();
$va_start = $o_tep->getHistoricDateParts($pa_historic_timestamps[0]);
$va_end = $o_tep->getHistoricDateParts($pa_historic_timestamps[1]);
if ($va_start['year'] < 0) {
$va_start['year'] = 1900;
}
if ($va_end['year'] >= 2000000) {
$va_end['year'] = date("Y");
}
return array('start' => $va_start, 'end' => $va_end, 'start_iso' => $o_tep->getISODateTime($va_start, 'FULL'), 'end_iso' => $o_tep->getISODateTime($va_end, 'FULL'));
}
示例2: caCalculateDateRangeAvgInDays
function caCalculateDateRangeAvgInDays()
{
$va_date_ranges = func_get_args();
$o_tep = new TimeExpressionParser();
$va_days = array();
foreach ($va_date_ranges as $vs_date_range) {
if (!$o_tep->parse($vs_date_range)) {
print "no parse {$vs_date_range}";
return false;
}
$va_arg_historic_stamps = $o_tep->getHistoricTimestamps();
$va_start_parts = $o_tep->getHistoricDateParts($va_arg_historic_stamps['start']);
$va_end_parts = $o_tep->getHistoricDateParts($va_arg_historic_stamps['end']);
$vs_start = $o_tep->getISODateTime($va_start_parts);
$vs_end = $o_tep->getISODateTime($va_end_parts);
$o_start = new DateTime($vs_start);
$o_end = new DateTime($vs_end);
$va_days[] = $o_start->diff($o_end)->days;
}
if (sizeof($va_days)) {
return array_sum($va_days) / sizeof($va_days);
} else {
return false;
}
}