本文整理汇总了PHP中Zend_Date::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Date::toArray方法的具体用法?PHP Zend_Date::toArray怎么用?PHP Zend_Date::toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Date
的用法示例。
在下文中一共展示了Zend_Date::toArray方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filterByExpirationDate
/**
* Apply filter by card expiration date (extract valid cards only)
*
* @return CLS_Paypal_Model_Resource_Customerstored_Collection
*/
public function filterByExpirationDate()
{
$now = new Zend_Date(null);
$dateArray = $now->toArray();
$this->getSelect()->where("\n (cc_exp_year > '{$dateArray['year']}') OR\n (cc_exp_year = '{$dateArray['year']}' AND cc_exp_month >= {$dateArray['month']})\n ");
return $this;
}
示例2: setValue
/**
* Sets the internal value to ISO date format.
*
* @param string|array $val String expects an ISO date format. Array notation with 'date' and 'time'
* keys can contain localized strings. If the 'dmyfields' option is used for {@link DateField},
* the 'date' value may contain array notation was well (see {@link DateField->setValue()}).
*/
function setValue($val)
{
if (empty($val)) {
$this->dateField->setValue(null);
$this->timeField->setValue(null);
} else {
// String setting is only possible from the database, so we don't allow anything but ISO format
if (is_string($val) && Zend_Date::isDate($val, $this->getConfig('datavalueformat'), $this->locale)) {
// split up in date and time string values.
$valueObj = new Zend_Date($val, $this->getConfig('datavalueformat'), $this->locale);
// set date either as array, or as string
if ($this->dateField->getConfig('dmyfields')) {
$this->dateField->setValue($valueObj->toArray());
} else {
$this->dateField->setValue($valueObj->get($this->dateField->getConfig('dateformat')));
}
// set time
$this->timeField->setValue($valueObj->get($this->timeField->getConfig('timeformat')));
} elseif (is_array($val) && array_key_exists('date', $val) && array_key_exists('time', $val)) {
$this->dateField->setValue($val['date']);
$this->timeField->setValue($val['time']);
} else {
$this->dateField->setValue($val);
$this->timeField->setValue($val);
}
}
}
示例3: unixToArray
/**
* Converte um timestamp para array
*
* @param int $timeStamp
* @return ARRAY
*/
public function unixToArray($timeStamp)
{
if (!$timeStamp)
return null;
$date = new Zend_Date();
$date->set($timeStamp, Zend_Date::TIMESTAMP);
return $date->toArray();
}
示例4: indexAction
public function indexAction()
{
// action body
$service = new Application_Model_DbTable_Service();
if ($this->getRequest()->isPost('select_date')) {
$year = $this->getRequest()->getPost('select_year');
$month = $this->getRequest()->getPost('select_month');
$_SESSION['year'] = $year;
$_SESSION['month'] = $month;
} else {
$currend_date = new Zend_Date();
$ss = $currend_date->toArray();
$year = $ss['year'];
$month = (int) $ss['month'];
if ($month < 10) {
$month = "0{$month}";
}
$_SESSION['year'] = $year;
$_SESSION['month'] = $month;
}
$date = "{$year}-{$month}";
//обработка параметров поиска
if ($this->getRequest()->isPost('search_catalog')) {
$search = $this->getRequest()->getPost('search_catalog');
} elseif ($this->getRequest()->getParam('search_catalog')) {
$search = $this->getRequest()->getParam('search_catalog');
}
//c поиском
if ($search != '') {
$this->view->service = $service->searchService($search);
$dd = $service->getcountsearchService($search);
$this->view->countshow = $dd[0]['count'];
//без поиска
} else {
$this->view->service = $service->showService($date);
$dd = $service->getcountService($date);
$this->view->countshow = $dd[0]['count'];
}
$dd = $service->getcountService($date);
$this->view->count = $dd[0]['count'];
$dd = $service->getcountService();
$this->view->allcount = $dd[0]['count'];
$this->view->search = $search;
}
示例5: testToArray
public function testToArray()
{
$date = new Zend_Date('2006-01-02 23:58:59', Zend_Date::ISO_8601, 'en_US');
$return = $date->toArray();
$orig = array('day' => 02, 'month' => 01, 'year' => 2006, 'hour' => 23, 'minute' => 58, 'second' => 59, 'timezone' => 'MVT', 'timestamp' => 1136228339, 'weekday' => 1, 'dayofyear' => 1, 'week' => '01', 'gmtsecs' => 18000);
$this->assertEquals($orig, $return);
}
示例6: saveAction
//.........这里部分代码省略.........
$path = Mage::getBaseDir('media') . DS;
$result = unlink($path . $data['image_full_content']['value']);
if ($data['full_height_resize'] && $data['full_width_resize']) {
$resizePath = Mage::getBaseDir('media') . DS . 'clmcenter' . DS . $data['full_width_resize'] . 'x' . $data['full_height_resize'] . DS;
}
$result = unlink($resizePath . str_replace('clmcenter/', '', $data['image_full_content']['value']));
$data['image_full_content'] = '';
} else {
if (isset($data['image_full_content']['value'])) {
$data['image_full_content'] = $data['image_full_content']['value'];
}
}
if (isset($data['use_full_img'])) {
if (isset($data['image_full_content'])) {
$data['image_short_content'] = $data['image_full_content'];
}
}
$model = Mage::getModel('clmcenter/mcenter');
$hoursFrom = $this->getRequest()->getParam('publicate_from_hours');
$minutesFrom = $this->getRequest()->getParam('publicate_from_minutes');
$hoursTo = $this->getRequest()->getParam('publicate_to_hours');
$minutesTo = $this->getRequest()->getParam('publicate_to_minutes');
$data['publicate_from_hours'] = $hoursFrom;
$data['publicate_from_minutes'] = $minutesFrom;
$data['publicate_to_hours'] = $hoursTo;
$data['publicate_to_minutes'] = $minutesTo;
$data['link'] = $this->getRequest()->getParam('link');
$data['tags'] = $this->getRequest()->getParam('tags');
// prepare dates
if ($this->getRequest()->getParam('mcenter_time') != '') {
$dateFormatIso = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
if (!Zend_Date::isDate($this->getRequest()->getParam('mcenter_time') . ' ' . date("H:i:s"), $dateFormatIso)) {
throw new Exception($this->__('Mcenter date field is required'));
}
$date = new Zend_Date($this->getRequest()->getParam('mcenter_time') . ' ' . date("H:i:s"), $dateFormatIso);
$dateInfo = $date->toArray();
$data['mcenter_time'] = preg_replace('/([0-9]{4})\\-(.*)/', $dateInfo['year'] . '-$2', $date->toString('YYYY-MM-dd HH:mm:ss'));
} else {
$data['mcenter_time'] = new Zend_Db_Expr('null');
}
if ($this->getRequest()->getParam('publicate_from_time') != '') {
if (!Zend_Date::isDate($this->getRequest()->getParam('publicate_from_time') . ' ' . $hoursFrom . ':' . $minutesFrom . ':00', $dateFormatIso)) {
throw new Exception($this->__('Mcenter date field is required'));
}
$date = new Zend_Date($this->getRequest()->getParam('publicate_from_time') . ' ' . $hoursFrom . ':' . $minutesFrom . ':00', $dateFormatIso);
$dateInfo = $date->toArray();
$data['publicate_from_time'] = preg_replace('/([0-9]{4})\\-(.*)/', $dateInfo['year'] . '-$2', $date->toString('YYYY-MM-dd HH:mm:ss'));
} else {
$data['publicate_from_time'] = new Zend_Db_Expr('null');
}
if ($this->getRequest()->getParam('publicate_to_time') != '') {
if (!Zend_Date::isDate($this->getRequest()->getParam('publicate_to_time') . ' ' . $hoursTo . ':' . $minutesTo . ':00', $dateFormatIso)) {
throw new Exception($this->__('Mcenter date field is required'));
}
$date = new Zend_Date($this->getRequest()->getParam('publicate_to_time') . ' ' . $hoursTo . ':' . $minutesTo . ':00', $dateFormatIso);
$dateInfo = $date->toArray();
$data['publicate_to_time'] = preg_replace('/([0-9]{4})\\-(.*)/', $dateInfo['year'] . '-$2', $date->toString('YYYY-MM-dd HH:mm:ss'));
} else {
$data['publicate_to_time'] = new Zend_Db_Expr('null');
}
$model->setData($data)->setId($this->getRequest()->getParam('id'));
try {
if ($this->getRequest()->getParam('mcenter_time') == NULL) {
$model->setMcenterTime(now());
$model->setCreatedTime(now());
} else {
if (isset($arr[0]) && !($mcenterItemId = $arr[0]['mcenter_id'])) {
$model->setCreatedTime(now());
}
}
$model->setUpdateTime(now());
if ($this->getRequest()->getParam('author') == NULL) {
$model->setUpdateAuthor(NULL);
/*$model->setAuthor(Mage::getSingleton('admin/session')->getUser()->getFirstname() .
" " . Mage::getSingleton('admin/session')->getUser()->getLastname())
->setUpdateAuthor(Mage::getSingleton('admin/session')->getUser()->getFirstname() .
" " . Mage::getSingleton('admin/session')->getUser()->getLastname());*/
} else {
$model->setUpdateAuthor(Mage::getSingleton('admin/session')->getUser()->getFirstname() . " " . Mage::getSingleton('admin/session')->getUser()->getLastname());
}
$model->save();
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('clmcenter')->__('Сохранено успешно!'));
Mage::getSingleton('adminhtml/session')->setFormData(false);
if ($this->getRequest()->getParam('back')) {
$this->_redirect('*/*/edit', array('id' => $model->getId()));
return;
}
$this->_redirect('*/*/');
return;
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
Mage::getSingleton('adminhtml/session')->setFormData($data);
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
return;
}
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('clmcenter')->__('Нет данных для сохранения'));
$this->_redirect('*/*/');
}
}
}
示例7: testArrayVerification
/**
* ZF-6457
*/
public function testArrayVerification()
{
$date = new Zend_Date();
$array = $date->toArray();
$this->assertTrue($this->_validator->isValid($array), "array expected to be valid");
}
示例8: setZendDate
/**
* Set date values from Zend_Date instance.
*
* @param Zend_Date $date Zend_Date instance to use.
* @return void
*/
public function setZendDate(Zend_Date $date)
{
$datearray = $date->toArray();
$this->setYear($datearray['year']);
$this->setMonth($datearray['month']);
$this->setDay($datearray['day']);
$this->setHour($datearray['hour']);
$this->setMinute($datearray['minute']);
$this->setSecond($datearray['second']);
$this->setTimezone($datearray['timezone']);
$this->setUnixTimestamp($date->getTimestamp());
}
示例9: isAllowedDate
/**
* Checks if date is allowed
* @param Zend_Date $Date
* @return bool
*/
public function isAllowedDate(Zend_Date $Date, $Product = null)
{
if ($Product && !$Product->getAwSarpHasShipping()) {
return true;
}
if (!$Product || $Product->getAwSarpHasShipping()) {
$arr = $Date->toArray();
$weekday = $arr['weekday'] == 7 ? 0 : $arr['weekday'];
return array_search($weekday, $this->getExcludedWeekdays()) === false;
} else {
return true;
}
}
示例10: toexcelmonthAction
public function toexcelmonthAction()
{
global $settings;
// Подключаем класс для работы с excel
require_once 'PHPExcel.php';
// Подключаем класс для вывода данных в формате excel
require_once 'PHPExcel/Writer/Excel5.php';
// Создаем объект класса PHPExcel
$xls = new PHPExcel();
// Устанавливаем индекс активного листа
$xls->setActiveSheetIndex(0);
// Получаем активный лист
$sheet = $xls->getActiveSheet();
// Подписываем лист
$sheet->setCellValue("A1", '№');
$sheet->setCellValue("B1", 'Дата');
$sheet->setCellValue("C1", 'Номер');
$sheet->setCellValue("D1", 'Жалоба');
$sheet->setCellValue("E1", 'Диагноз');
$sheet->setCellValue("F1", 'Работа');
$sheet->setCellValue("G1", 'Запчасти');
$sheet->setCellValue("H1", 'Коментарии');
//меняем цвет заголовка
$sheet->getStyle('A1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
$sheet->getStyle('A1')->getFill()->getStartColor()->setRGB('EEEEEE');
$sheet->getStyle('B1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
$sheet->getStyle('B1')->getFill()->getStartColor()->setRGB('EEEEEE');
$sheet->getStyle('C1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
$sheet->getStyle('C1')->getFill()->getStartColor()->setRGB('EEEEEE');
$sheet->getStyle('D1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
$sheet->getStyle('D1')->getFill()->getStartColor()->setRGB('EEEEEE');
$sheet->getStyle('E1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
$sheet->getStyle('E1')->getFill()->getStartColor()->setRGB('EEEEEE');
$sheet->getStyle('F1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
$sheet->getStyle('F1')->getFill()->getStartColor()->setRGB('EEEEEE');
$sheet->getStyle('G1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
$sheet->getStyle('G1')->getFill()->getStartColor()->setRGB('EEEEEE');
$sheet->getStyle('H1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
$sheet->getStyle('H1')->getFill()->getStartColor()->setRGB('EEEEEE');
$sheet->getStyle('A')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
// автоматическая ширина ячейки
$sheet->getColumnDimension('A')->setAutoSize(true);
$sheet->getColumnDimension('B')->setAutoSize(true);
$sheet->getColumnDimension('C')->setAutoSize(true);
$sheet->getColumnDimension('D')->setAutoSize(true);
$sheet->getColumnDimension('E')->setAutoSize(true);
$sheet->getColumnDimension('F')->setAutoSize(true);
$sheet->getColumnDimension('G')->setAutoSize(true);
$sheet->getColumnDimension('H')->setAutoSize(true);
// формат ячейки текстовый
$sheet->getStyle('A')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
$sheet->getStyle('B')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
$sheet->getStyle('C')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
$sheet->getStyle('D')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
$sheet->getStyle('E')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
$sheet->getStyle('F')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
$sheet->getStyle('G')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
$sheet->getStyle('H')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
if (isset($_SESSION['year']) && isset($_SESSION['month'])) {
$year = $_SESSION['year'];
$month = $_SESSION['month'];
} else {
$currend_date = new Zend_Date();
$ss = $currend_date->toArray();
$year = $ss['year'];
$month = (int) $ss['month'];
if ($month < 10) {
$month = "0{$month}";
}
$_SESSION['year'] = $year;
$_SESSION['month'] = $month;
}
$date = "{$year}-{$month}";
$repairs = new Application_Model_DbTable_Repairs();
$data = $repairs->statisticRepairs($date);
$i = 2;
$sheet->setTitle("Repairs {$date}");
foreach ($data as $rows) {
$number = $i - 1;
$sheet->setCellValue("A{$i}", "{$number}");
$sheet->setCellValue("B{$i}", "{$rows['date']}");
$sheet->setCellValue("C{$i}", "{$rows['number']}");
$sheet->setCellValue("D{$i}", "{$rows['claim']}");
$sheet->setCellValue("E{$i}", "{$rows['diagnos']}");
$sheet->setCellValue("F{$i}", "{$rows['work']}");
$sheet->setCellValue("G{$i}", "{$rows['spares']}");
$sheet->setCellValue("H{$i}", "{$rows['comments']}");
$i++;
}
// Выводим содержимое файла
$objWriter = new PHPExcel_Writer_Excel5($xls);
$objWriter->save('repairs_mounth.xls');
// открываем файл в бинарном режиме
header("Location: http://{$settings['excel']['site']}/repairs_mounth.xls");
}