本文整理汇总了PHP中DateHelper类的典型用法代码示例。如果您正苦于以下问题:PHP DateHelper类的具体用法?PHP DateHelper怎么用?PHP DateHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DateHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTweets
public static function getTweets($twitter_user)
{
$i = 0;
$twitter_url = 'http://twitter.com/statuses/user_timeline/' . $twitter_user . '.xml?count=4';
$tweets = array();
if ($buffer = @file_get_contents($twitter_url)) {
libxml_use_internal_errors();
try {
$xml = @new \SimpleXMLElement($buffer);
if ($xml->status) {
foreach ($xml->status as $status) {
$tweet = $status->text;
$date = $status->created_at;
$id = $status->id;
//Turn all urls, hastags, and @mentions into links
$tweet = preg_replace("#(^|[\n ])([\\w]+?://[\\w]+[^ \"\n\r\t< ]*)#", "\\1<a href=\"\\2\">\\2</a>", $tweet);
$tweet = preg_replace("#(^|[\n ])((www|ftp)\\.[^ \"\t\n\r< ]*)#", "\\1<a href=\"http://\\2\">\\2</a>", $tweet);
$tweet = preg_replace("/@(\\w+)/", "<a href=\"http://twitter.com/\\1\">@\\1</a>", $tweet);
$tweet = preg_replace("/#(\\w+)/", "<span class='twitter_hash'><a href=\"http://search.twitter.com/search?q=\\1\">#\\1</a></span>", $tweet);
$formatted_date = DateHelper::formatDate($date);
$tweets[$i]['tweet'] = $tweet;
$tweets[$i]['date'] = $formatted_date;
$i++;
}
}
} catch (\Exception $e) {
}
}
return $tweets;
}
示例2: exportPDF
function exportPDF()
{
$app = JFactory::getApplication();
$input = $app->input;
AImporter::helper('pdf', 'date');
AImporter::model('transportreports');
$model = new BookproModelTransportReports();
$depart_date = DateHelper::createFromFormatYmd($input->get('filter_depart_date'));
$state = $model->getState();
$state->set('list.limit', NULL);
$state->set('list.start', 0);
$state->set('list.ordering', 'pickup');
$state->set('list.direction', 'ASC');
if ($app->isAdmin()) {
$ticket_view = $this->getView('Transportreports', 'html', 'BookProView');
} else {
$ticket_view = $this->getView('AgentTransportreports', 'html', 'BookProView');
$ticket_view->is_admin = 1;
}
$ticket_view->setModel($model, true);
$ticket_view->setLayout('report');
ob_start();
$ticket_view->display();
$pdf = ob_get_contents();
ob_end_clean();
//get flight name
$order = new JObject();
$order->name = "transport_report" . $input->get('filter_depart_date') . '_' . JHtml::_('date', 'now', 'YmdHis');
$order->fontsize = 9;
PrintPdfHelper::printTicket($pdf, $order, 'P');
return;
}
示例3: populateState
protected function populateState($ordering = null, $direction = null)
{
// Load the filter state.
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$order_status = $this->getUserStateFromRequest($this->context . '.filter.order_status', 'filter_order_status', null, 'string');
$this->setState('filter.order_status', $order_status);
$from_time = $this->getUserStateFromRequest($this->context . '.filter.from_time', 'filter_from_time', null, 'string');
$this->setState('filter.from_time', $from_time);
$to_time = $this->getUserStateFromRequest($this->context . '.filter.to_time', 'filter_to_time', null, 'string');
$this->setState('filter.to_time', $to_time);
$type = $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type', null, 'int');
$this->setState('filter.type', $type);
$destfrom = $this->getUserStateFromRequest($this->context . '.filter.destfrom', 'filter_destfrom', null, 'int');
$this->setState('filter.destfrom', $destfrom);
$destto = $this->getUserStateFromRequest($this->context . '.filter.destto', 'filter_destto', null, 'int');
$this->setState('filter.destto', $destto);
$route_id = $this->getUserStateFromRequest($this->context . '.filter.route_id', 'filter_route_id', null, 'int');
$this->setState('filter.route_id', $route_id);
parent::populateState('i.start', 'ASC');
$fromdate = $this->getUserStateFromRequest($this->context . '.filter.from_date', 'filter_from_date', null, 'string');
$fromdate = DateHelper::createFromFormatYmd($fromdate);
$this->setState('filter.from_date', $fromdate);
$todate = $this->getUserStateFromRequest($this->context . '.filter.to_date', 'filter_to_date', null, 'string');
$todate = DateHelper::createFromFormatYmd($todate);
$this->setState('filter.to_date', $todate);
}
示例4: populateState
protected function populateState($ordering = null, $direction = null)
{
AImporter::helper('date');
parent::populateState();
$app = JFactory::getApplication();
$id = JRequest::getVar('id', 0, '', 'int');
$this->setState('passengerlist.id', $id);
// Load the filter state.
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$order_id = $this->getUserStateFromRequest($this->context . '.filter.order_id', 'filter_order_id', null, 'int');
$this->setState('filter.order_id', $order_id);
$tour_id = $this->getUserStateFromRequest($this->context . '.filter.tour_id', 'filter_tour_id', null, 'int');
$this->setState('filter.tour_id', $tour_id);
$depart_date = $this->getUserStateFromRequest($this->context . '.filter.depart_date', 'filter_depart_date', null);
$depart_date = DateHelper::createFromFormatYmd($depart_date);
$this->setState('filter.depart_date', $depart_date);
$order_status = $this->getUserStateFromRequest($this->context . '.filter.order_status', 'filter_order_status', null, 'string');
$this->setState('filter.order_status', $order_status);
$value = $app->getUserStateFromRequest($this->context . '.ordercol', 'filter_order', $ordering);
$this->setState('list.ordering', $value);
$value = $app->getUserStateFromRequest($this->context . '.orderdirn', 'filter_order_Dir', $direction);
$this->setState('list.direction', $value);
$fromdate = $this->getUserStateFromRequest($this->context . '.filter.from_date', 'filter_from_date', null, 'string');
$fromdate = DateHelper::createFromFormatYmd($fromdate);
$this->setState('filter.from_date', $fromdate);
$todate = $this->getUserStateFromRequest($this->context . '.filter.to_date', 'filter_to_date', null, 'string');
$todate = DateHelper::createFromFormatYmd($todate);
$this->setState('filter.to_date', $todate);
}
示例5: getContent
function getContent()
{
$hp = Codendi_HTMLPurifier::instance();
$content = '';
if ($this->rss_url) {
require_once 'common/rss/libs/SimplePie/simplepie.inc';
if (!is_dir($GLOBALS['codendi_cache_dir'] . '/rss')) {
mkdir($GLOBALS['codendi_cache_dir'] . '/rss');
}
$rss = new SimplePie($this->rss_url, $GLOBALS['codendi_cache_dir'] . '/rss', null, $GLOBALS['sys_proxy']);
$max_items = 10;
$items = array_slice($rss->get_items(), 0, $max_items);
$content .= '<table width="100%">';
$i = 0;
foreach ($items as $item) {
$content .= '<tr class="' . util_get_alt_row_color($i++) . '"><td WIDTH="99%">';
if ($image = $item->get_link(0, 'image')) {
//hack to display twitter avatar
$content .= '<img src="' . $hp->purify($image, CODENDI_PURIFIER_CONVERT_HTML) . '" width="48" height="48" style="float:left; margin-right:1em;" />';
}
$content .= '<a href="' . $item->get_link() . '">' . $hp->purify($item->get_title(), CODENDI_PURIFIER_STRIP_HTML) . '</a>';
if ($item->get_date()) {
$content .= '<span style="color:#999;" title="' . format_date($GLOBALS['Language']->getText('system', 'datefmt'), $item->get_date('U')) . '"> - ' . DateHelper::timeAgoInWords($item->get_date('U')) . '</span>';
}
$content .= '</td></tr>';
}
$content .= '</table>';
}
return $content;
}
示例6: display
function display($tpl = null)
{
$this->config = JBFactory::getConfig();
$input = JFactory::getApplication()->input;
AImporter::model('tour');
$cart = JModelLegacy::getInstance('TourCart', 'bookpro');
$cart->load();
$cart->clear();
$model = new BookProModelTour();
$id = $input->getInt('id');
$this->tour = $model->getComplexItem($id);
$this->itineraries = TourHelper::buildItinerary($id);
//$this->packages = $packages;
$date = TourHelper::getDateFirstInPackagerateFromTourid($this->tour->id);
$this->date = JFactory::getDate($date)->format(DateHelper::getConvertDateFormat('P'));
$this->tour->rdate = $this->date;
$dispatcher = JDispatcher::getInstance();
//$this->_prepareDocument();
// $dispatcher = JDispatcher::getInstance();
// $this->event = new stdClass();
// JPluginHelper::importPlugin('bookpro');
// $results = $dispatcher->trigger('onBookproProductAfterTitle', array ($this->tour));
// $this->event->afterDisplayTitle=isset($results[0])?$results[0]:null;
parent::display($tpl);
}
示例7: formatTourDate
public static function formatTourDate($str, $glue)
{
$date = explode(',', $str);
$result = array();
for ($i = 0; $i < count($date); $i++) {
$result[] = DateHelper::formatDate($date[$i]);
}
return implode($glue, $result);
}
示例8: index
function index($fecha = null)
{
if ($fecha == null) {
$fecha = date("d-m-Y");
}
$fecha = DateHelper::dateFormat($fecha, 'd-m-Y Y-m-d');
$this->set('fecha', $fecha);
$this->set('datos', $this->Reporte->reporteHorasDia($fecha));
}
示例9: getForm
public function getForm($data = array(), $loadData = true)
{
$form = $this->loadForm('com_bookpro.customer', 'customer', array('control' => 'jform', 'load_data' => $loadData));
$form->setFieldAttribute('birthday', 'format', DateHelper::getConvertDateFormat('M'));
if (empty($form)) {
return false;
}
return $form;
}
示例10: before_filter
public function before_filter()
{
$this->filter();
$this->layout = false;
$this->current_version = Version::find('first', array('select' => 'versions.*', 'joins' => 'INNER JOIN packages on versions.package_id = packages.id INNER JOIN users ON users.id = packages.user_id', 'order' => 'versions.created_at DESC'));
$date = DateHelper::from_db($this->current_version->created_at);
$date = date(DATE_RFC822, $date);
$this->header("Last-Modified: {$date}");
}
示例11: __get
public function __get($format)
{
if (in_array($format, TimeHelper::$formats)) {
return TimeHelper::to_string($format, $this->time);
}
if (in_array($format, DateHelper::$formats)) {
return DateHelper::to_string($format, $this->time);
}
}
示例12: up
public function up()
{
$table = $this->alter_table('users');
$table->timestamp('channel_updated');
$table->go();
foreach (User::find_all() as $user) {
$user->channel_updated = DateHelper::to_string('db', time());
$user->save();
}
}
开发者ID:scottdavis,项目名称:pearfarm_channel_server,代码行数:10,代码来源:1262148568_add_channel_updated_to_users_migration.php
示例13: getRemoteRepositoryInfoError
private function getRemoteRepositoryInfoError()
{
$date = DateHelper::timeAgoInWords($this->project_creator_status->getEventDate($this->repository), false, true);
$url = GIT_BASE_URL . '/?action=repo_management&group_id=' . $this->repository->getProjectId() . '&repo_id=' . $this->repository->getId() . '&pane=gerrit';
$html = '';
$html .= '<div class="alert alert-error gerrit_url">';
$html .= $GLOBALS['Language']->getText('plugin_git', 'delegated_to_gerrit_error', array($date, $url), CODENDI_PURIFIER_DISABLED);
$html .= '</div>';
return $html;
}
示例14: ini
public function ini()
{
$date1 = date(NORMALDATEFORMAT);
$date1test = DateHelper::formatDateFromNormalToDatabase($date1);
$this->setVars("pureDate1", $date1);
$this->setVars("formattedDate1", $date1test);
$date2 = date(DATABASEDATEFORMAT);
$date2test = DateHelper::formatDateFromDatabaseToNormal($date2);
$this->setVars("pureDate2", $date2);
$this->setVars("formattedDate2", $date2test);
$date3 = date(NORMALDATEFORMAT);
$date3test = DateHelper::formatDateFromNormalToCustom('d#m#Y', $date3);
$this->setVars("pureDate3", $date3);
$this->setVars("formattedDate3", $date3test);
$date4 = date('d#m#Y');
$date4test = DateHelper::formatDateFromCustomToNormal('d#m#Y', $date4);
$this->setVars("pureDate4", $date4);
$this->setVars("formattedDate4", $date4test);
$time1 = date(NORMALTIMEFORMAT);
$time1test = DateHelper::formatTimeFromNormalToDatabase($time1);
$this->setVars("pureTime1", $time1);
$this->setVars("formattedTime1", $time1test);
$time2 = date(DATABASETIMEFORMAT);
$time2test = DateHelper::formatTimeFromDatabaseToNormal($time2);
$this->setVars("pureTime2", $time2);
$this->setVars("formattedTime2", $time2test);
$time3 = date(NORMALTIMEFORMAT);
$time3test = DateHelper::formatTimeFromNormalToCustom("H#i#s", $time3);
$this->setVars("pureTime3", $time3);
$this->setVars("formattedTime3", $time3test);
$time4 = date('H#i#s');
$time4test = DateHelper::formatTimeFromCustomToNormal("H#i#s", $time4);
$this->setVars("pureTime4", $time4);
$this->setVars("formattedTime4", $time4test);
$dateTime1 = date(NORMALDATETIMEFORMAT);
$dateTime1test = DateHelper::formatDateTimeFromNormalToDatabase($dateTime1);
$this->setVars("pureDateTime1", $dateTime1);
$this->setVars("formattedDateTime1", $dateTime1test);
$dateTime2 = date(DATABASEDATETIMEFORMAT);
$dateTime2test = DateHelper::formatDateTimeFromDatabaseToNormal($dateTime2);
$this->setVars("pureDateTime2", $dateTime2);
$this->setVars("formattedDateTime2", $dateTime2test);
$dateTime3 = date(NORMALDATETIMEFORMAT);
$dateTime3test = DateHelper::formatDateTimeFromNormalToCustom("d#m#Y H#i#s", $dateTime3);
$this->setVars("pureDateTime3", $dateTime3);
$this->setVars("formattedDateTime3", $dateTime3test);
$dateTime4 = date('d#m#Y H#i#s');
$dateTime4test = DateHelper::formatDateTimeFromCustomToNormal("d#m#Y H#i#s", $dateTime4);
$this->setVars("pureDateTime4", $dateTime4);
$this->setVars("formattedDateTime4", $dateTime4test);
$this->view('testDate');
}
示例15: getDayWeek
static function getDayWeek($name)
{
AImporter::helper('date');
$days = DateHelper::dayofweek();
$daysweek = array();
foreach ($days as $key => $value) {
$object = new stdClass();
$object->key = $key;
$object->value = $value;
$daysweek[] = $object;
}
$selected = array_keys($days);
return AHtml::checkBoxList($daysweek, $name, '', $selected, 'key', 'value');
}