本文整理汇总了PHP中JDate类的典型用法代码示例。如果您正苦于以下问题:PHP JDate类的具体用法?PHP JDate怎么用?PHP JDate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JDate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authenticate
/**
* Tries to authenticate the user and start the backup, or send him back to the default task
*/
function authenticate()
{
// Enforce raw mode - I need to be in full control!
$format = JRequest::getCmd('format', 'html');
if ($format != 'raw') {
$this->setRedirect(JURI::base() . 'index.php?option=com_joomlapack&view=light&format=raw');
parent::redirect();
} else {
if (!$this->_checkPermissions()) {
parent::redirect();
} else {
$this->_setProfile();
jimport('joomla.utilities.date');
jpimport('core.cube');
JoomlapackCUBE::reset();
$cube =& JoomlapackCUBE::getInstance();
$user =& JFactory::getUser();
$userTZ = $user->getParam('timezone', 0);
$dateNow = new JDate();
$dateNow->setOffset($userTZ);
$cube->start(JText::_('DEFAULT_COMMENT') . ' ' . $dateNow->toFormat(JText::_('DATE_FORMAT_LC2'), ''));
$cube->save();
$this->setRedirect(JURI::base() . 'index.php?option=com_joomlapack&view=light&task=step&key=' . JRequest::getVar('key') . '&profile=' . JRequest::getInt('profile') . '&format=raw');
}
}
}
示例2: removefromset
/**
* remove from set
*/
function removefromset()
{
$model = $this->getModel();
$table = $model->getTable();
$key = $table->getKeyName();
$urlVar = $key;
$jinput = JFactory::getApplication()->input;
$recordId = $jinput->getInt($urlVar);
$recurrence_group = $jinput->getInt('recurrence_group');
# Retrieve id of current event from recurrence_table
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('id');
$query->from($db->quoteName('#__jem_recurrence'));
$query->where(array('groupid_ref = ' . $recurrence_group, 'itemid= ' . $recordId));
$db->setQuery($query);
$recurrenceid = $db->loadResult();
# Update field recurrence_group in event-table
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->update('#__jem_events');
$query->set(array('recurrence_count = ""', 'recurrence_freq = ""', 'recurrence_group = ""', 'recurrence_interval = ""', 'recurrence_until = ""', 'recurrence_weekday = ""'));
$query->where('id = ' . $recordId);
$db->setQuery($query)->query();
# Blank field groupid_ref in recurrence-table and set exdate value
$recurrence_table = JTable::getInstance('Recurrence', 'JEMTable');
$recurrence_table->load($recurrenceid);
$startdate_org_input = new JDate($recurrence_table->startdate_org);
$exdate = $startdate_org_input->format('Ymd\\THis\\Z');
$recurrence_table->exdate = $exdate;
$recurrence_table->groupid_ref = "";
$recurrence_table->store();
# redirect back
$this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId, $urlVar), false));
}
示例3: display
/**
* Starts a backup
* @return
*/
function display()
{
// Check permissions
$this->_checkPermissions();
// Set the profile
$this->_setProfile();
// Force the output to be of the raw format type
JRequest::setVar('format', 'raw');
$document =& JFactory::getDocument();
$document->setType('raw');
// Get the description, if present; otherwise use the default description
jimport('joomla.utilities.date');
$user =& JFactory::getUser();
$userTZ = $user->getParam('timezone', 0);
$dateNow = new JDate();
$dateNow->setOffset($userTZ);
$default_description = JText::_('BACKUP_DEFAULT_DESCRIPTION') . ' ' . $dateNow->toFormat(JText::_('DATE_FORMAT_LC2'));
$description = JRequest::getString('description', $default_description);
// Start the backup (CUBE Operation)
jpimport('core.cube');
JoomlapackCUBE::reset();
$cube =& JoomlapackCUBE::getInstance();
$cube->start($description, '');
$cube->save();
// Return the JSON output
parent::display(false);
}
示例4: export
function export($event)
{
CFactory::load('helpers', 'event');
$handler = CEventHelper::getHandler($event);
if (!$handler->showExport()) {
echo JText::_('CC ACCESS FORBIDDEN');
return;
}
header('Content-type: text/Calendar');
header('Content-Disposition: attachment; filename="calendar.ics"');
$creator = CFactory::getUser($event->creator);
$offset = $creator->getUtcOffset();
$date = new JDate($event->startdate);
$dtstart = $date->toFormat('%Y%m%dT%H%M%S');
$date = new JDate($event->enddate);
$dtend = $date->toFormat('%Y%m%dT%H%M%S');
$url = $handler->getFormattedLink('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id, false, true);
$tmpl = new CTemplate();
$tmpl->set('dtstart', $dtstart);
$tmpl->set('dtend', $dtend);
$tmpl->set('url', $url);
$tmpl->set('event', $event);
$raw = $tmpl->fetch('events.ical');
unset($tmpl);
echo $raw;
exit;
}
示例5: getList
public static function getList(&$params)
{
$db = JFactory::getDbo();
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
$timeframe = $params->get('timeframe', 'alltime');
$maximum = $params->get('maximum', 5);
$order_value = $params->get('order_value', 'count');
if ($order_value == 'rand()') {
$order_direction = '';
} else {
$order_value = $db->quoteName($order_value);
$order_direction = $params->get('order_direction', 1) ? 'DESC' : 'ASC';
}
$query = $db->getQuery(true)->select(array('MAX(' . $db->quoteName('tag_id') . ') AS tag_id', ' COUNT(*) AS count', 'MAX(t.title) AS title', 'MAX(' . $db->quoteName('t.access') . ') AS access', 'MAX(' . $db->quoteName('t.alias') . ') AS alias'))->group($db->quoteName(array('tag_id', 'title', 'access', 'alias')))->from($db->quoteName('#__contentitem_tag_map'))->where($db->quoteName('t.access') . ' IN (' . $groups . ')');
// Only return published tags
$query->where($db->quoteName('t.published') . ' = 1 ');
// Optionally filter on language
$language = JComponentHelper::getParams('com_tags')->get('tag_list_language_filter', 'all');
if ($language != 'all') {
if ($language == 'current_language') {
$language = JHelperContent::getCurrentLanguage();
}
$query->where($db->quoteName('t.language') . ' IN (' . $db->quote($language) . ', ' . $db->quote('*') . ')');
}
if ($timeframe != 'alltime') {
$now = new JDate();
$query->where($db->quoteName('tag_date') . ' > ' . $query->dateAdd($now->toSql('date'), '-1', strtoupper($timeframe)));
}
$query->join('INNER', $db->quoteName('#__tags', 't') . ' ON ' . $db->quoteName('tag_id') . ' = t.id')->order($order_value . ' ' . $order_direction);
$db->setQuery($query, 0, $maximum);
$results = $db->loadObjectList();
return $results;
}
示例6: loadByIP
public function loadByIP($ip, $mode = self::ACTIVE)
{
// Reset the table.
$k = $this->_tbl_key;
$this->{$k} = 0;
$this->reset();
// Check for a valid id to load.
if ($ip === null || !is_string($ip)) {
return false;
}
$now = new JDate();
// Load the user data.
$query = "SELECT * FROM {$this->_tbl}\n\t\t\tWHERE ip = {$this->_db->quote($ip)}\n\t\t\t" . ($mode == self::ACTIVE ? "AND (expiration = {$this->_db->quote($this->_db->getNullDate())} OR expiration > {$this->_db->quote($now->toMysql())})" : '') . "\n\t\t\tORDER BY id DESC";
$this->_db->setQuery($query, 0, 1);
$data = $this->_db->loadAssoc();
// Check for an error message.
if ($this->_db->getErrorNum()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
if (empty($data)) {
$this->ip = $ip;
return false;
}
// Bind the data to the table.
$this->bind($data);
return true;
}
示例7: authenticate
/**
* Tries to authenticate the user and start the backup, or send him back to the default task
*/
public function authenticate()
{
// Enforce raw mode - I need to be in full control!
if (!$this->_checkPermissions()) {
parent::redirect();
} else {
$session = JFactory::getSession();
$session->set('litemodeauthorized', 1, 'akeeba');
$this->_setProfile();
JLoader::import('joomla.utilities.date');
AECoreKettenrad::reset(array('maxrun' => 0));
AEUtilTempvars::reset(AKEEBA_BACKUP_ORIGIN);
$kettenrad = AECoreKettenrad::load(AKEEBA_BACKUP_ORIGIN);
$dateNow = new JDate();
/*
$user = JFactory::getUser();
$userTZ = $user->getParam('timezone',0);
$dateNow->setOffset($userTZ);
*/
$description = JText::_('BACKUP_DEFAULT_DESCRIPTION') . ' ' . $dateNow->format(JText::_('DATE_FORMAT_LC2'), true);
$options = array('description' => $description, 'comment' => '');
$kettenrad->setup($options);
$ret = $kettenrad->tick();
AECoreKettenrad::save(AKEEBA_BACKUP_ORIGIN);
JFactory::getApplication()->redirect(JURI::base() . 'index.php?option=com_akeeba&view=light&task=step&key=' . urlencode($this->input->get('key', '', 'none', 2)) . '&profile=' . $this->input->get('profile', 1, 'int') . '&format=raw');
}
}
示例8: __construct
function __construct(&$_db)
{
parent::__construct('#__banner', 'bid', $_db);
jimport('joomla.utilities.date');
$now = new JDate();
$this->set('date', $now->toMySQL());
}
示例9: getShortDate
/**
* Returns date/time in short format. i.e. 6m, 6h, 6d, 6w, 6m, 6y etc
* @param unknown $date
* @return Ambigous <string, string, mixed, multitype:>|Ambigous <string, string, mixed>
*/
public static function getShortDate($date)
{
if (empty($date) || $date == '0000-00-00 00:00:00') {
return JText::_('LBL_NA');
}
jimport('joomla.utilities.date');
$user = JFactory::getUser();
// Given time
$date = new JDate(JHtml::date($date, 'Y-m-d H:i:s'));
$compareTo = new JDate(JHtml::date('now', 'Y-m-d H:i:s'));
$diff = $compareTo->toUnix() - $date->toUnix();
$diff = abs($diff);
$dayDiff = floor($diff / 86400);
if ($dayDiff == 0) {
if ($diff < 120) {
return '1m';
} elseif ($diff < 3600) {
return floor($diff / 60) . 'm';
} else {
return floor($diff / 3600) . 'h';
}
} elseif ($dayDiff < 7) {
return $dayDiff . 'd';
} elseif ($dayDiff < 7 * 6) {
return ceil($dayDiff / 7) . 'w';
} elseif ($dayDiff < 365) {
return ceil($dayDiff / (365 / 12)) . 'm';
} else {
return round($dayDiff / 365) . 'y';
}
}
示例10: save
function save($data)
{
$row =& JTable::getInstance('codefile', 'Table');
$id = $data['id'];
if (!$id) {
jimport('joomla.utilities.date');
$dateNow = new JDate();
$dateMySql = $dateNow->toMySQL();
$data['creationdate'] = $dateMySql;
$data['addedby'] = 'server';
}
if (!$row->bind($data)) {
JError::raiseError(500, $row->getError());
return false;
}
if (!$row->check()) {
JError::raiseError(500, $row->getError());
}
if (!$row->store()) {
JError::raiseError(500, $row->getError());
return false;
} else {
if (!$id) {
$row->load($row->{$id});
}
if ($_FILES['cfile']['size']) {
$this->fileupdload($row->id);
}
}
return true;
}
示例11: stdClass
function &getData()
{
if (empty($this->_data)) {
$query = ' SELECT * FROM #__fst_comments ' . ' WHERE id = ' . FSTJ3Helper::getEscaped($this->_db, $this->_id);
$this->_db->setQuery($query);
$this->_data = $this->_db->loadObject();
}
if (!$this->_data) {
$this->_data = new stdClass();
$this->_data->id = 0;
$this->_data->ident = 5;
//
$this->_data->itemid = 0;
$this->_data->body = null;
$this->_data->email = null;
$this->_data->name = null;
$this->_data->website = null;
$this->_data->published = 1;
$current_date = new JDate();
if (FSTJ3Helper::IsJ3()) {
$mySQL_conform_date = $current_date->toSql();
} else {
$mySQL_conform_date = $current_date->toMySQL();
}
$this->_data->created = $mySQL_conform_date;
}
return $this->_data;
}
示例12: savePayment
function savePayment()
{
$orderid = JRequest::getVar('orderid');
$Itemid = JRequest::getVar('Itemid');
$order = JTable::getInstance('OrdersTable', 'JTheFactory');
if (!$order->load($orderid)) {
$app = JFactory::getApplication();
$app->redirect('index.php?option=' . APP_EXTENSION . '&Itemid=' . $Itemid, JText::_("FACTORY_ORDER_DOES_NOT_EXIST"));
return;
}
$paylog = JTable::getInstance('PaymentLogTable', 'JTheFactory');
$date = new JDate();
$paylog->date = $date->toMySQL();
$paylog->amount = $order->order_total;
$paylog->currency = $order->order_currency;
$paylog->refnumber = JRequest::getVar('customer_note');
$paylog->invoice = $orderid;
$paylog->ipn_response = print_r($_REQUEST, true);
$paylog->ipn_ip = $_SERVER['REMOTE_ADDR'];
$paylog->status = 'manual_check';
$paylog->userid = $order->userid;
$paylog->orderid = $order->id;
$paylog->payment_method = $this->name;
$paylog->store();
$order->paylogid = $paylog->id;
$order->store();
}
示例13: store
public function store()
{
$now = new JDate();
// Always update the stream last updated time
$this->updated = $now->toMySQL();
return parent::store();
}
示例14: formatDate
public static function formatDate($date, $format = null, $jsFormat = true)
{
if (is_null($format)) {
if (!($format = self::getDateFormat())) {
reset(self::$_dateFormats);
$format = key(self::$_dateFormats);
}
}
if ($jsFormat) {
if (isset(self::$_dateFormats[$format])) {
$format = self::$_dateFormats[$format];
} else {
$format = reset(self::$_dateFormats);
}
}
if ($date instanceof DateTime) {
$timestamp = $date->getTimestamp();
} else {
if (is_int($date)) {
$timestamp = $date;
} else {
$timestamp = strtotime((string) $date);
}
}
//return date($format, $timestamp);
$dt = new JDate($date);
return $dt->format($format);
}
示例15: getList
function getList(&$params)
{
global $mainframe;
$db =& JFactory::getDBO();
$user =& JFactory::getUser();
$userId = (int) $user->get('id');
$count = (int) $params->get('count', 5);
$catid = trim($params->get('catid'));
$secid = trim($params->get('secid'));
$show_front = $params->get('show_front', 1);
$aid = $user->get('aid', 0);
$contentConfig =& JComponentHelper::getParams('com_content');
$access = !$contentConfig->get('shownoauth');
$nullDate = $db->getNullDate();
jimport('joomla.utilities.date');
$date = new JDate();
$now = $date->toMySQL();
$where = 'a.state = 1' . ' AND ( a.publish_up = ' . $db->Quote($nullDate) . ' OR a.publish_up <= ' . $db->Quote($now) . ' )' . ' AND ( a.publish_down = ' . $db->Quote($nullDate) . ' OR a.publish_down >= ' . $db->Quote($now) . ' )';
// User Filter
switch ($params->get('user_id')) {
case 'by_me':
$where .= ' AND (created_by = ' . (int) $userId . ' OR modified_by = ' . (int) $userId . ')';
break;
case 'not_me':
$where .= ' AND (created_by <> ' . (int) $userId . ' AND modified_by <> ' . (int) $userId . ')';
break;
}
// Ordering
switch ($params->get('ordering')) {
case 'm_dsc':
$ordering = 'a.modified DESC, a.created DESC';
break;
case 'c_dsc':
default:
$ordering = 'a.created DESC';
break;
}
if ($catid) {
$ids = explode(',', $catid);
JArrayHelper::toInteger($ids);
$catCondition = ' AND (cc.id=' . implode(' OR cc.id=', $ids) . ')';
}
if ($secid) {
$ids = explode(',', $secid);
JArrayHelper::toInteger($ids);
$secCondition = ' AND (s.id=' . implode(' OR s.id=', $ids) . ')';
}
// Content Items only
$query = 'SELECT a.*, ' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,' . ' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug' . ' FROM #__content AS a' . ($show_front == '0' ? ' LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id' : '') . ' INNER JOIN #__categories AS cc ON cc.id = a.catid' . ' INNER JOIN #__sections AS s ON s.id = a.sectionid' . ' WHERE ' . $where . ' AND s.id > 0' . ($access ? ' AND a.access <= ' . (int) $aid . ' AND cc.access <= ' . (int) $aid . ' AND s.access <= ' . (int) $aid : '') . ($catid ? $catCondition : '') . ($secid ? $secCondition : '') . ($show_front == '0' ? ' AND f.content_id IS NULL ' : '') . ' AND s.published = 1' . ' AND cc.published = 1' . ' ORDER BY ' . $ordering;
$db->setQuery($query, 0, $count);
$rows = $db->loadObjectList();
$i = 0;
$lists = array();
foreach ($rows as $row) {
$lists[$i]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid));
$lists[$i]->text = htmlspecialchars($row->title);
$i++;
}
return $lists;
}