本文整理汇总了PHP中Zend_Date::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Date::set方法的具体用法?PHP Zend_Date::set怎么用?PHP Zend_Date::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Date
的用法示例。
在下文中一共展示了Zend_Date::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: informationAction
/**
*
*/
public function informationAction()
{
// Form Information
$formInformation = $this->_initForm('information');
$id = $this->_getParam('id');
$data = array();
if (!empty($id)) {
$row = $this->_mapper->fetchRow($id);
$data = $row->toArray();
$date = new Zend_Date();
$data['registration_date'] = $date->set($data['registration_date'])->toString('dd/MM/yyyy');
$data['open_date'] = $date->set($data['open_date'])->toString('dd/MM/yyyy');
$data['close_date'] = $date->set($data['close_date'])->toString('dd/MM/yyyy');
$data['start_salary'] = number_format($data['start_salary'], 2, '.', '');
$data['finish_salary'] = number_format($data['finish_salary'], 2, '.', '');
$data['additional_salary'] = number_format($data['additional_salary'], 2, '.', '');
if (!empty($data['start_job_date'])) {
$data['start_job_date'] = $date->set($data['start_job_date'])->toString('dd/MM/yyyy');
}
if (!$this->view->jobActive()->hasAccessEdit()) {
$formInformation->getElement('save')->setAttrib('disabled', true);
}
} else {
$data['fk_id_dec'] = Zend_Auth::getInstance()->getIdentity()->fk_id_dec;
}
$formInformation->populate($data);
$this->view->form = $formInformation;
}
示例2: listByFilters
/**
*
* @param array $filters
* @return Zend_Db_Table_Rowset
*/
public function listByFilters($filters = array())
{
$dbAudit = App_Model_DbTable_Factory::get('SysAudit');
$dbForm = App_Model_DbTable_Factory::get('SysForm');
$dbModule = App_Model_DbTable_Factory::get('SysModule');
$dbUser = App_Model_DbTable_Factory::get('SysUser');
$select = $dbAudit->select()->from(array('a' => $dbAudit))->setIntegrityCheck(false)->join(array('f' => $dbForm), 'f.id_sysform = a.fk_id_sysform', array('form', 'date_audit' => new Zend_Db_Expr('DATE_FORMAT( a.date_time, "%d/%m/%Y" )')))->join(array('m' => $dbModule), 'm.id_sysmodule = a.fk_id_sysmodule', array('module'))->join(array('u' => $dbUser), 'u.id_sysuser = a.fk_id_sysuser', array('name'))->order(array('date_time DESC'));
$date = new Zend_Date();
if (!empty($filters['start_date']) && Zend_Date::isDate($filters['start_date'])) {
$select->where('DATE( a.date_time ) >= ?', $date->set($filters['start_date'])->toString('yyyy-MM-dd'));
}
if (!empty($filters['finish_date']) && Zend_Date::isDate($filters['finish_date'])) {
$select->where('DATE( a.date_time ) <= ?', $date->set($filters['finish_date'])->toString('yyyy-MM-dd'));
}
if (!empty($filters['fk_id_sysuser'])) {
$select->where('a.fk_id_sysuser = ?', $filters['fk_id_sysuser']);
}
if (!empty($filters['fk_id_sysmodule'])) {
$select->where('a.fk_id_sysmodule = ?', $filters['fk_id_sysmodule']);
}
if (!empty($filters['fk_id_sysform'])) {
$select->where('a.fk_id_sysform = ?', $filters['fk_id_sysform']);
}
if (!empty($filters['description'])) {
$select->where('a.description LIKE ?', '%' . $filters['description'] . '%');
}
return $dbAudit->fetchAll($select);
}
示例3: formDate
/**
* Generates a set of radio button elements.
*
* @access public
*
* @param string|array $name If a string, the element name. If an
* array, all other parameters are ignored, and the array elements
* are extracted in place of added parameters.
*
* @param mixed $value The radio value to mark as 'checked'.
*
* @param array $options An array of key-value pairs where the array
* key is the radio value, and the array value is the radio text.
*
* @param array|string $attribs Attributes added to each radio.
*
* @return string The radio buttons XHTML.
*/
public function formDate($name, $value = null, $attribs = null, $options = null, $listsep = "<br />\n")
{
if (is_string($value)) {
$parsedValue = array();
list($parsedValue['year'], $parsedValue['month'], $parsedValue['day']) = @explode('-', $value, 3);
list($parsedValue['day'], $time) = @explode(' ', $parsedValue['day'], 2);
$value = $parsedValue;
}
if (!is_array($value)) {
$value = null;
}
$info = $this->_getInfo($name, $value, $attribs, $options, $listsep);
extract($info);
// name, value, attribs, options, listsep, disable
$localeObject = Zend_Registry::get('Locale');
// Translate year names from locale
$yearFormat = $localeObject->getTranslation('yyyy', 'dateitem', $localeObject);
if ($yearFormat) {
$date = new Zend_Date();
foreach ($options['year'] as $key => &$val) {
if ($key <= 0) {
continue;
}
$date->set($key, Zend_Date::YEAR);
$val = $date->toString($yearFormat, 'iso', $localeObject);
}
}
// Translate month names from locale
$monthLabels = $localeObject->getTranslationList('Month', $localeObject);
if (isset($options['month'][0]) && count($monthLabels) + 1 == count($options['month'])) {
array_unshift($monthLabels, '');
}
if (count($monthLabels) == count($options['month'])) {
$options['month'] = array_combine(array_keys($options['month']), array_values($monthLabels));
}
// Translate day names from locale
$dayFormat = $localeObject->getTranslation('d', 'dateitem', $localeObject);
if ($dayFormat) {
$date = new Zend_Date();
$date->set(1, Zend_Date::MONTH);
foreach ($options['day'] as $key => &$val) {
if ($key <= 0) {
continue;
}
$date->set($key, Zend_Date::DAY);
$val = $date->toString($dayFormat, 'iso', $localeObject);
}
}
// Get order from locale
$dateLocaleString = $localeObject->getTranslation('long', 'Date', $localeObject);
$dateLocaleString = preg_replace('~\'[^\']+\'~', '', $dateLocaleString);
$dateLocaleString = strtolower($dateLocaleString);
$dateLocaleString = preg_replace('/[^mdy]/i', '', $dateLocaleString);
$dateLocaleString = preg_replace(array('/(m)+/', '/(d)+/', '/(y)+/'), array(' %2$s ', ' %3$s ', ' %1$s '), $dateLocaleString);
$dateLocaleString = preg_replace('/ +/i', ' ', trim($dateLocaleString));
return sprintf($dateLocaleString, $this->view->formSelect($name . '[year]', $value['year'], $attribs, $options['year']), $this->view->formSelect($name . '[month]', $value['month'], $attribs, $options['month']), $this->view->formSelect($name . '[day]', $value['day'], $attribs, $options['day']));
}
示例4: findallAction
public function findallAction()
{
if ($value_id = $this->getRequest()->getParam('value_id')) {
try {
$option = $this->getCurrentOptionValue();
$start_at = new Zend_Date();
$end_at = new Zend_Date();
$format = 'y-MM-dd HH:mm:ss';
$offset = $this->getRequest()->getParam('offset', 0);
$events = $option->getObject()->getEvents($offset);
$data = array('collection' => array());
foreach ($events as $key => $event) {
$start_at->set($event->getStartAt(), $format);
$end_at->set($event->getEndAt(), $format);
$formatted_start_at = $start_at->toString($this->_("MM.dd.y"));
$subtitle2 = $this->_("Entrance: %s", $event->getStartTimeAt());
if ($event->getLocationLabel()) {
$subtitle2 .= " | " . $this->_("Location: %s", $event->getLocationLabel());
}
$data['collection'][] = array("id" => $key, "title" => $event->getName(), "title2" => "{$start_at->toString(Zend_Date::WEEKDAY_NAME)} {$formatted_start_at}", "name" => $event->getName(), "subtitle" => $event->getSubtitle(), "subtitle2" => $subtitle2, "description" => $event->getDescription(), "month_name_short" => $start_at->toString(Zend_Date::MONTH_NAME_SHORT), "day" => $start_at->toString('dd'), "weekday_name" => $start_at->toString(Zend_Date::WEEKDAY_NAME), "start_time_at" => $event->getStartTimeAt(), "location" => $event->getLocation(), "url" => $this->getPath("event/mobile_view/index", array('value_id' => $option->getId(), "event_id" => $key)));
}
$data['page_title'] = $option->getTabbarName();
$data['displayed_per_page'] = Event_Model_Event::DISPLAYED_PER_PAGE;
} catch (Exception $e) {
$data = array('error' => 1, 'message' => $e->getMessage());
}
$this->_sendHtml($data);
}
}
示例5: testDate
public function testDate()
{
//$date = new Zend_Date('12:01',Zend_Date::TIME_SHORT);
$date = new Zend_Date();
$time = '12:01';
$date->set($time, Zend_Date::TIME_SHORT);
}
示例6: convertDateToStoreTimestamp
public function convertDateToStoreTimestamp($date, $store = null)
{
try {
if (Mage::getStoreConfigFlag('xtcore/compatibility_fixes/disable_timestamp_timezone_adjustment')) {
$dateObj = new Zend_Date();
$dateObj->set($date, Varien_Date::DATETIME_INTERNAL_FORMAT);
return (int) $dateObj->get(null, Zend_Date::TIMESTAMP);
}
$dateObj = new Zend_Date();
$dateObj->setTimezone(Mage_Core_Model_Locale::DEFAULT_TIMEZONE);
$dateObj->set($date, Varien_Date::DATETIME_INTERNAL_FORMAT);
$dateObj->setLocale(Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE, $store));
$dateObj->setTimezone(Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE, $store));
$gmtOffset = $dateObj->getGmtOffset();
if ($gmtOffset >= 0) {
if (Mage::getStoreConfigFlag('xtcore/compatibility_fixes/zend_date_gmt_offset')) {
// Note: Some Zend_Date versions always return a positive $gmtOffset. Thus, we replace + with - below if affected by this.
return (int) $dateObj->get(null, Zend_Date::TIMESTAMP) - $gmtOffset;
} else {
return (int) $dateObj->get(null, Zend_Date::TIMESTAMP) + $gmtOffset;
}
} else {
return (int) $dateObj->get(null, Zend_Date::TIMESTAMP) - $gmtOffset;
}
} catch (Exception $e) {
return null;
}
}
示例7: filter
/**
*
* @param string $value
* @return Zend_Date
*/
public function filter($value){
$d = new Zend_Date();
$d->setTimezone('Europe/London');
$d->set($value, 'yyyy-MM-dd hh-mm-ss');
$d->setTimezone();
return $d;
}
示例8: getDate
/**
* Returns the date.
*
* @return Zend_Date
*/
public function getDate()
{
$date = new Zend_Date(0);
$date->setTimezone('UTC');
$date->set($this->getText(), $this->_format ? $this->_format : Zend_Date::ISO_8601);
return $date;
}
示例9: uploadAction
public function uploadAction()
{
if (isset($_FILES['importfile']) && !empty($_FILES['importfile']['name'])) {
$content = file_get_contents($_FILES['importfile']['tmp_name']);
$lines = explode("\n", $content);
$persons = array();
//'BDAY'
$state = 0;
foreach ($lines as $line) {
$line = str_replace("\r", "", $line);
$pos = strpos($line, ':');
if ($pos === false) {
continue;
}
$key = substr($line, 0, $pos);
$value = substr($line, $pos + 1);
switch ($state) {
case 0:
if ($key === 'BEGIN' && $value === 'VCARD') {
$state = 1;
$person = array();
}
break;
case 1:
if ($key === 'END' && $value === 'VCARD') {
$state = 0;
$persons[] = $person;
} else {
if ($key === 'FN' || substr($key, 0, 3) === 'FN;') {
$name = explode(' ', $value);
$person['firstname'] = strip_tags($name[0]);
$person['secondname'] = strip_tags($name[1]);
}
if ($key === 'BDAY' || substr($key, 0, 5) === 'BDAY;') {
$value = substr($value, 0, 10);
$date = new Zend_Date();
if ($date->isDate($value, 'yyyy-MM-dd')) {
$date->set($value);
$person['birthdate'] = $date->toString('yyyy-MM-dd');
}
}
}
break;
}
}
}
foreach ($persons as $person) {
if (isset($person['firstname']) && isset($person['secondname']) && isset($person['birthdate'])) {
$user = new Bc_UserDTO();
$user->set('firstname', $person['firstname']);
$user->set('secondname', $person['secondname']);
$user->set('birthdate', $person['birthdate']);
$user->save();
}
}
$this->_redirect('/');
}
示例10: __construct
public function __construct($noMonths, Zend_Date $startDate = null)
{
$this->_noMonths = (int) $noMonths;
if (is_null($startDate)) {
$startDate = new Zend_Date();
$startDate->set(1, Zend_Date::DAY);
}
$this->_startDate = $startDate;
$this->buildCalendar();
}
示例11: addTime
/**
*
* Enter description here ...
* @param unknown_type $time
* @param unknown_type $format
* @return ExecutionTime
* @throws Exception
*/
public function addTime($time, $format = 'HH:mm:ss')
{
if (!\Zend_Date::isDate($time, $format)) {
throw new \Exception('time invalid ' . $time);
}
$date = new \Zend_Date();
$date->set($time, $format);
$this->dates[] = $date;
return $this;
}
示例12: _firstWeekday
/**
*
* @access protected
* @return int
*/
protected function _firstWeekday()
{
$day = (int) $this->_date->toString('dd');
//Seleciona primeiro dia do mes
$this->_date->set(1, Zend_Date::DAY);
//Dia da semana
$weekday = $this->_date->get(Zend_Date::WEEKDAY_DIGIT);
$this->_date->set($day, Zend_Date::DAY);
return $weekday;
}
示例13: 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();
}
示例14: getDateFromDb
/**
* Convert given date string with UTC timezone into default locale format
* and locale timezone
*
* @param string $date date string in SQL format with UTC timezone
* @return Zend_Date
*/
public static function getDateFromDb($date)
{
if (!is_string($date)) {
throw new Zmz_Date_Exception('$date must be a string');
}
$tmpDate = new Zend_Date();
$tmpDate->setTimezone('UTC');
$tmpDate->set($date, self::SQL_DATETIME);
$tmpDate->setTimezone(Zmz_Culture::getTimezone());
return $tmpDate;
}
示例15: buildSQl
/**
* Zwraca zapytanie SQL
*
* @return string
*/
public function buildSQl()
{
$select = $this->dbModelTable->select();
$select->setIntegrityCheck(false)->from(array('ss' => 'sms.storage'), array(new Zend_Db_Expr('DISTINCT ON (id) ss.*')))->joinRight(array('sss' => 'sms.storage_status'), 'ss.id = sss.sms_storage_id', array())->joinLeft(array('wc' => 'ws.client'), 'wc.id = ss.ws_client_id', array('client_name'))->joinLeft(array('ws' => 'ws.service_sms'), 'ws.id = ss.ws_service_sms_id', array('service_login'))->joinLeft(array('sr' => 'ws.recipient_sms'), 'sr.id = ss.sms_recipient_id', array('recipient' => 'phone_number'))->where('sr.id = ?', $this->id);
if (isset($this->filterdata['client_id']) && !empty($this->filterdata['client_id'])) {
$select->where('ss.ws_client_id = ?', $this->filterdata['client_id']);
}
if (isset($this->filterdata['service_id']) && !empty($this->filterdata['service_id'])) {
$select->where('ss.ws_service_sms_id = ?', $this->filterdata['service_id']);
}
$date = new Zend_Date();
if (isset($this->filterdata['date_for']) && !empty($this->filterdata['date_for']) && isset($this->filterdata['date_to']) && !empty($this->filterdata['date_to'])) {
$select->where('ss.created_at BETWEEN \'' . $date->set($this->filterdata['date_for'])->get(Zend_Date::ISO_8601) . '\' AND \'' . $date->set($this->filterdata['date_to'])->addDay(1)->get(Zend_Date::ISO_8601) . '\'');
} elseif (isset($this->filterdata['date_for']) && !empty($this->filterdata['date_for'])) {
$select->where('ss.created_at >= ?', $date->set($this->filterdata['date_for'])->get(Zend_Date::ISO_8601));
} elseif (isset($this->filterdata['date_to']) && !empty($this->filterdata['date_to'])) {
$select->where('ss.created_at <= ?', $date->set($this->filterdata['date_to'])->addDay(1)->get(Zend_Date::ISO_8601));
}
return $select->__toString();
}