本文整理汇总了PHP中JDate::toFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP JDate::toFormat方法的具体用法?PHP JDate::toFormat怎么用?PHP JDate::toFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JDate
的用法示例。
在下文中一共展示了JDate::toFormat方法的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: loadChartData
function loadChartData()
{
$db = $this->getDBO();
$type = JRequest::getCmd('type');
switch ($type) {
case 'sales':
jimport('joomla.utilities.date');
$date = JFactory::getDate();
$interval = JRequest::getInt('interval', '14');
$today = $date->toFormat('%Y-%m-%d');
$startDate = strtotime('-' . $interval . ' day', strtotime($today));
$startDate = new JDate($startDate);
$query = "SELECT COUNT(virtuemart_order_id) AS sales, DATE(created_on) as `date` FROM #__virtuemart_orders WHERE created_on > " . $db->Quote($startDate->toMySQL()) . " GROUP BY `date` ORDER BY `date`";
$db->setQuery($query);
$rows = $db->loadObjectList();
$data = array();
foreach ($rows as $row) {
$data[$row->date] = (int) $row->sales;
}
$today = $date->toUnix();
for ($time = $startDate->toUnix(); $time <= $today; $time += 86400) {
$date = date('Y', $time) . '-' . date('m', $time) . '-' . date('d', $time);
if (!array_key_exists($date, $data)) {
$data[$date] = 0;
}
}
ksort($data);
$startYear = $startDate->toFormat('%Y');
$startMonth = $startDate->toFormat('%m') - 1;
$startDay = $startDate->toFormat('%d');
$script = "\r\n k2martSalesChartOptions.title.text = '" . JText::_('K2MART_TOTAL_SALES', true) . "';\r\n k2martSalesChartOptions.subtitle.text = '* " . JText::_('K2MART_CLICK_AND_DRAG_IN_THE_PLOT_AREA_TO_ZOOM_IN', true) . "';\r\n k2martSalesChartOptions.yAxis.title.text = '" . JText::_('K2MART_SALES', true) . "';\r\n k2martSalesChartOptions.series[0].pointStart=Date.UTC(" . $startYear . ", " . $startMonth . ", " . $startDay . "); \r\n k2martSalesChartOptions.series[0].data=[" . implode(',', $data) . "];\r\n ";
break;
case 'products':
$limit = JRequest::getInt('limit', '20');
$query = "SELECT product.product_sales, productData.product_name FROM #__virtuemart_products AS product \r\n LEFT JOIN #__virtuemart_products_" . VMLANG . " AS productData ON product.virtuemart_product_id = productData.virtuemart_product_id\r\n WHERE product.product_sales > 0 ORDER BY product.product_sales DESC LIMIT 0, {$limit}";
$db->setQuery($query);
$rows = $db->loadObjectList();
$data = array();
$categories = array();
foreach ($rows as $row) {
$data[] = (int) $row->product_sales;
$categories[] = "'" . $row->product_name . "'";
}
$script = "\r\n k2martProductsChartOptions.title.text = '" . JText::_('K2MART_TOP_SELLING_PRODUCTS', true) . "';\r\n k2martProductsChartOptions.yAxis.title.text = '" . JText::_('K2MART_SALES', true) . "';\r\n k2martProductsChartOptions.xAxis.categories =[" . implode(',', $categories) . "]; \r\n k2martProductsChartOptions.series[0].data=[" . implode(',', $data) . "];\r\n ";
break;
}
$script .= "k2martChartType = '{$type}';";
echo $script;
}
示例3: getToday
static function getToday($ym = false)
{
jimport('joomla.utilities.date');
$format = $ym == true ? '%Y-%m' : '%Y-%m-%d';
$today_do = new JDate();
return $today_do->toFormat($format);
}
示例4: 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!
$document =& JFactory::getDocument();
$document->setType('raw');
if (!$this->_checkPermissions()) {
parent::redirect();
} else {
$session =& JFactory::getSession();
$session->set('litemodeauthorized', 1, 'akeeba');
$this->_setProfile();
jimport('joomla.utilities.date');
AECoreKettenrad::reset();
$memory_filename = AEUtilTempvars::get_storage_filename(AKEEBA_BACKUP_ORIGIN);
@unlink($memory_filename);
$kettenrad =& AECoreKettenrad::load(AKEEBA_BACKUP_ORIGIN);
$user =& JFactory::getUser();
$userTZ = $user->getParam('timezone', 0);
$dateNow = new JDate();
$dateNow->setOffset($userTZ);
if (AKEEBA_JVERSION == '16') {
$description = JText::_('BACKUP_DEFAULT_DESCRIPTION') . ' ' . $dateNow->format(JText::_('DATE_FORMAT_LC2'), true);
} else {
$description = JText::_('BACKUP_DEFAULT_DESCRIPTION') . ' ' . $dateNow->toFormat(JText::_('DATE_FORMAT_LC2'));
}
$options = array('description' => $description, 'comment' => '');
$kettenrad->setup($options);
$ret = $kettenrad->tick();
AECoreKettenrad::save(AKEEBA_BACKUP_ORIGIN);
$this->setRedirect(JURI::base() . 'index.php?option=com_akeeba&view=light&task=step&key=' . urlencode(JRequest::getVar('key')) . '&profile=' . JRequest::getInt('profile') . '&format=raw');
}
}
示例5: 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);
}
示例6: display
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');
// Start the backup
jimport('joomla.utilities.date');
jpimport('core.cube');
JoomlapackCUBE::reset();
$cube =& JoomlapackCUBE::getInstance();
$jconfig =& JFactory::getConfig();
$userTZ = $jconfig->get('config.offset');
/*
$user =& JFactory::getUser();
$userTZ = $user->getParam('timezone',0);
*/
$dateNow = new JDate();
$dateNow->setOffset($userTZ);
$cube->start(JText::_('BACKUP_DEFAULT_DESCRIPTION') . ' ' . $dateNow->toFormat(JText::_('DATE_FORMAT_LC2'), ''));
$cube->save();
$this->setRedirect(JURI::base() . 'index.php?option=com_joomlapack&view=backup&task=step&key=' . JRequest::getVar('key') . '&profile=' . JRequest::getInt('profile', 1) . '&format=raw');
parent::display();
}
示例7: 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;
}
示例8: formatDate
public static function formatDate($date)
{
if (count($date) > 0) {
$i = 0;
$cur_date = new JDate($date);
$f_date = $cur_date->toFormat("%B %d, %Y");
}
return $f_date;
}
示例9: get_local_timestamp
/**
* Returns the current timestamp, taking into account any TZ information,
* in the format specified by $format.
* @param string $format Timestamp format string (standard PHP format string)
* @return string
*/
public function get_local_timestamp($format)
{
jimport('joomla.utilities.date');
$jregistry = JFactory::getConfig();
$tzDefault = $jregistry->getValue('config.offset');
$user = JFactory::getUser();
$tz = $user->getParam('timezone', $tzDefault);
$dateNow = new JDate('now', $tz);
return $dateNow->toFormat($format);
}
示例10: display
public function display()
{
// Check permissions
$this->_checkPermissions();
// Set the profile
$this->_setProfile();
// Start the backup
jimport('joomla.utilities.date');
AECoreKettenrad::reset();
$memory_filename = AEUtilTempvars::get_storage_filename(AKEEBA_BACKUP_ORIGIN);
@unlink($memory_filename);
$kettenrad =& AECoreKettenrad::load(AKEEBA_BACKUP_ORIGIN);
$user =& JFactory::getUser();
$userTZ = $user->getParam('timezone',0);
$dateNow = new JDate();
$dateNow->setOffset($userTZ);
if( AKEEBA_JVERSION == '16' ) {
$description = JText::_('BACKUP_DEFAULT_DESCRIPTION').' '.$dateNow->format(JText::_('DATE_FORMAT_LC2'), true);
} else {
$description = JText::_('BACKUP_DEFAULT_DESCRIPTION').' '.$dateNow->toFormat(JText::_('DATE_FORMAT_LC2'));
}
$options = array(
'description' => $description,
'comment' => ''
);
$kettenrad->setup($options);
$array = $kettenrad->tick();
$array = $kettenrad->tick();
AECoreKettenrad::save(AKEEBA_BACKUP_ORIGIN);
if($array['Error'] != '')
{
// An error occured
die('500 ERROR -- '.$array['Error']);
}
else
{
$noredirect = JRequest::getInt('noredirect', 0);
if($noredirect != 0)
{
@ob_end_clean();
echo "301 More work required";
flush();
JFactory::getApplication()->close();
}
else
{
$this->setRedirect(JURI::base().'index.php?option=com_akeeba&view=backup&task=step&key='.JRequest::getVar('key').'&profile='.JRequest::getInt('profile',1));
}
}
}
示例11: check
/**
* Overloaded check function
*
* @access public
* @return boolean
* @see JTable::check
* @since 1.5
*/
function check()
{
if (empty($this->alias)) {
$this->alias = $this->name;
}
$this->alias = JFilterOutput::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '') {
$datenow = new JDate();
$this->alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S");
}
return true;
}
示例12: getDescription
/**
* Returns the backup description
*
* @param bool $noDefault Set to true to avoid setting a default
* @return string
*/
function getDescription($noDefault = false)
{
$description = JRequest::getString('description');
if (empty($description) && !$noDefault) {
jimport('joomla.utilities.date');
$user =& JFactory::getUser();
$userTZ = $user->getParam('timezone', 0);
$dateNow = new JDate();
$dateNow->setOffset($userTZ);
return JText::_('BACKUP_DEFAULT_DESCRIPTION') . ' ' . $dateNow->toFormat(JText::_('DATE_FORMAT_LC2'));
}
return $description;
}
示例13: build
function build()
{
return JDom::_('html.fly.datetime', $this->options);
//DEPRECATED : Use fly.datetime
$formatedDate = "";
if ($this->dataValue && $this->dataValue != "0000-00-00" && $this->dataValue != "00:00:00" && $this->dataValue != "0000-00-00 00:00:00") {
jimport("joomla.utilities.date");
$date = new JDate($this->dataValue);
$formatedDate = $date->toFormat($this->dateFormat);
}
$this->addClass('grid-date');
$html = '<span <%STYLE%><%CLASS%><%SELECTORS%>>' . $formatedDate . '</span>';
return $html;
}
示例14: getList
function getList(&$params)
{
//get database
$db =& JFactory::getDBO();
$query = 'SELECT MONTH( created ) AS created_month, created, id, sectionid, title, YEAR(created) AS created_year' . ' FROM #__content' . ' WHERE ( state = -1 AND checked_out = 0 )' . ' GROUP BY created_year DESC, created_month DESC';
$db->setQuery($query, 0, intval($params->get('count')));
$rows = $db->loadObjectList();
$menu =& JSite::getMenu();
$item = $menu->getItems('link', 'index.php?option=com_content&view=archive', true);
$itemid = isset($item) ? '&Itemid=' . $item->id : '';
$i = 0;
$lists = array();
foreach ($rows as $row) {
$date = new JDate($row->created);
$created_month = $date->toFormat("%m");
$month_name = $date->toFormat("%B");
$created_year = $date->toFormat("%Y");
$lists[$i]->link = JRoute::_('index.php?option=com_content&view=archive&year=' . $created_year . '&month=' . $created_month . $itemid);
$lists[$i]->text = $month_name . ', ' . $created_year;
$i++;
}
return $lists;
}
示例15: check
/**
* Overloaded check function
*
* @access public
* @return boolean
* @see JTable::check
* @since 1.5
*/
function check()
{
// check for valid name
if (trim($this->title) == '') {
$this->setError(JText::_('Your Poll must contain a title.'));
return false;
}
// check for valid lag
$this->lag = intval($this->lag);
if ($this->lag == 0) {
$this->setError(JText::_('Your Poll must have a non-zero lag time.'));
return false;
}
if (empty($this->alias)) {
$this->alias = $this->title;
}
$this->alias = JFilterOutput::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '') {
$datenow = new JDate();
$this->alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S");
}
return true;
}