本文整理汇总了PHP中Zend_Date::getTimestamp方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Date::getTimestamp方法的具体用法?PHP Zend_Date::getTimestamp怎么用?PHP Zend_Date::getTimestamp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Date
的用法示例。
在下文中一共展示了Zend_Date::getTimestamp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preparaDados
/**
* Prepara os dados para processar o arquivo do webservice
*
* @param string $sArquivo
* @return bool
* @throws Exception
*/
public function preparaDados($sArquivo)
{
try {
// Foi comentado o if de verificação pois estava ocorrendo um problema na emissão e retornava um arquivo em branco.
// Somente em ambiente de desenvolvimento
//if (APPLICATION_ENV == 'development') {
$oDomDocument = new DOMDocument();
$oDomDocument->loadXml($sArquivo);
$oData = new Zend_Date();
$this->sNomeArquivo = "/RecepcionarLote-{$oData->getTimestamp()}.xml";
$this->sCaminhoArquivo = TEMP_PATH;
/**
* Verifica se o caminho do arquivo não existe recria a pasta
*/
if (!file_exists($this->sCaminhoArquivo)) {
mkdir($this->sCaminhoArquivo, 0777);
}
/**
* Escreve os dados no arquivo
*/
$this->sCaminhoNomeArquivo = $this->sCaminhoArquivo . $this->sNomeArquivo;
$aArquivo = fopen($this->sCaminhoNomeArquivo, 'w');
fputs($aArquivo, print_r($sArquivo, TRUE));
fclose($aArquivo);
//}
$oValidacao = new DBSeller_Helper_Xml_AssinaturaDigital($sArquivo);
/**
* Validação digital do arquivo
*/
if (!$oValidacao->validar()) {
throw new Exception($oValidacao->getLastError());
}
$oUsuario = Administrativo_Model_Usuario::getByAttribute('cnpj', $oValidacao->getCnpj());
if (!is_object($oUsuario)) {
throw new Exception('Usuário contribuinte não existe!', 157);
}
/**
* Busca usuário contribuinte através do usuário cadastrado
*/
$aUsuarioContribuinte = Administrativo_Model_UsuarioContribuinte::getByAttributes(array('usuario' => $oUsuario->getId(), 'cnpj_cpf' => $oUsuario->getCnpj()));
if (!is_object($aUsuarioContribuinte[0])) {
throw new Exception('Usuário contribuinte não encontrado!', 160);
}
/**
* Seta os dados do contribuinte
*/
$this->oDadosUsuario = $oUsuario;
$this->oContribuinte->sCpfCnpj = $aUsuarioContribuinte[0]->getCnpjCpf();
$this->oContribuinte->iCodigoUsuario = $oUsuario->getId();
$this->oContribuinte->iIdUsuarioContribuinte = $aUsuarioContribuinte[0]->getId();
/**
* Atualiza os dados do contribuinte na sessão
*/
$oSessao = new Zend_Session_Namespace('nfse');
$oSessao->contribuinte = Contribuinte_Model_Contribuinte::getById($this->oContribuinte->iIdUsuarioContribuinte);
return TRUE;
} catch (Exception $oErro) {
throw new Exception($oErro->getMessage(), $oErro->getCode());
}
}
示例2: getDays
/**
* @param date $d data a ser comparada
*/
public function getDays($d)
{
$now = time();
$date = new Zend_Date($d, Zend_Date::ISO_8601);
$time = $now - $date->getTimestamp();
if ($time < 86400) {
//60*60*24
$time = 'hoje';
} elseif ($time < 172800) {
//60*60*24*2
$time = 'ontem';
//mostrar quantidade de dias até 14 dias
} elseif ($time < 604800) {
//60*60*24*30
$time = 'há ' . round(floatval($time) / 86400) . ' dias';
//mostrar quantidades de semanas apartir da 2 semana até 1 mes
} elseif ($time > 1209600 && $time <= 2592000) {
//60*60*24*(7*4)
$time = 'há ' . round(floatval($time) / 604800) . ' semanas';
} elseif ($time > 2592000 && $time <= 5184000) {
//60*60*24*30 && 60*60*24*30*2
$time = 'há ' . round(floatval($time) / 2592000) . ' mês';
} elseif ($time > 5184000 && $time < 31104000) {
//60*60*24*30*2 && 60*60*24*30*12
$time = 'há ' . round(floatval($time) / 2592000) . ' meses';
} else {
//if ($time < 31104000) { //60*60*24*30*12
$time = 'há mais de um ano (' . $date->toString() . ')';
}
return $time;
}
示例3: timing
public function timing($time)
{
$date = new Zend_Date();
$diffTime = $date->getTimestamp() - $time;
$date = null;
if ($diffTime < 60) {
return ($diffTime <= 0 ? 1 : $diffTime) . '秒前';
}
$minute = ceil($diffTime / 60);
if ($minute < 60) {
return $minute . '分钟前';
}
$minute = ceil($diffTime / 3600);
if ($minute < 24) {
return $minute . '小时前';
}
$day = ceil($diffTime / 3600 / 24);
if ($day < 30) {
return $day . '天前';
}
$month = ceil($diffTime / 3600 / 24 / 30);
if ($month < 12) {
return $month . '月前';
}
$year = floor($diffTime / 3600 / 24 / 30 / 12);
return $year . '年前';
}
示例4: execute
public function execute($lastRunDt = null)
{
$config = Zend_Registry::get('config');
$checkDtStart = new Zend_Date($this->_lastRunDt);
$checkDtEnd = new Zend_Date();
$event = new Event();
$events = $event->getEvents(null, null, null, $checkDtStart->getTimestamp(), $checkDtEnd->getTimestamp(), 'open');
$location = new Location();
$workshop = new Workshop();
$instructor = new Event_Instructor();
$attendee = new Event_Attendee();
$eu = new Evaluation_User();
foreach ($events as $e) {
$startDt = strtotime($e->date . ' ' . $e->startTime);
$endDt = strtotime($e->date . ' ' . $e->endTime);
if ($checkDtStart->getTimestamp() < $endDt && $checkDtEnd->getTimestamp() >= $endDt) {
echo 'Event to Send:';
var_dump($e->toArray(), '<br /><br />');
$thisLocation = $location->find($e->locationId);
if (is_null($thisLocation)) {
throw new Ot_Exception_Data('msg-error-noLocation');
}
$thisWorkshop = $workshop->find($e->workshopId);
if (is_null($thisWorkshop)) {
throw new Ot_Exception_Data('msg-error-noWorkshop');
}
$instructors = $instructor->getInstructorsForEvent($e->eventId);
$instructorNames = array();
$instructorEmails = array();
foreach ($instructors as $i) {
$instructorNames[] = $i['firstName'] . ' ' . $i['lastName'];
$instructorEmails[] = $i['emailAddress'];
}
$data = array('workshopName' => $thisWorkshop->title, 'workshopDate' => date('m/d/Y', $startDt), 'workshopStartTime' => date('g:i a', $startDt), 'workshopEndTime' => date('g:i a', $endDt), 'workshopMinimumEnrollment' => $e->minSize, 'workshopCurrentEnrollment' => $e->roleSize, 'locationName' => $thisLocation->name, 'locationAddress' => $thisLocation->address, 'instructorNames' => implode(', ', $instructorNames), 'instructorEmails' => implode(', ', $instructorEmails));
$attenders = $attendee->getAttendeesForEvent($e->eventId, 'attending', true);
foreach ($attenders as $a) {
$trigger = new Ot_Trigger();
$trigger->setVariables($data);
$trigger->accountId = $a['accountId'];
$trigger->studentEmail = $a['emailAddress'];
$trigger->studentName = $a['firstName'] . ' ' . $a['lastName'];
$trigger->studentUsername = $a['username'];
$trigger->dispatch('Event_Evaluation_Notification');
}
}
}
}
示例5: getForWebserviceExport
/**
* Returns the current tag's data for web service export
* @param mixed $params
* @abstract
* @return array
*/
public function getForWebserviceExport($document = null, $params = [])
{
if ($this->date) {
return $this->date->getTimestamp();
} else {
return null;
}
}
示例6: getForWebserviceExport
/**
* Returns the current tag's data for web service export
*
* @abstract
* @return array
*/
public function getForWebserviceExport()
{
if ($this->date) {
return $this->date->getTimestamp();
} else {
return null;
}
}
示例7: isStillValid
public function isStillValid()
{
$validTo = time() - (int) $this->getConfig()->get('re-request/log_vadility_lifetime');
$createdAt = new Zend_Date($this->getCreatedAt());
$previousCheckouts = (int) $this->getCheckoutsAfterThisRequest();
$maxCheckouts = (int) $this->getConfig()->get('re-request/max_number_of_checkouts');
return $previousCheckouts < $maxCheckouts && $validTo <= $createdAt->getTimestamp();
}
示例8: toTimestamp
/**
* Convert date to UNIX timestamp
* Returns current UNIX timestamp if date is true
*
* @param Zend_Date|string|bool $date
* @return int
*/
public static function toTimestamp($date)
{
if ($date instanceof Zend_Date) {
return $date->getTimestamp();
}
if ($date === true) {
return time();
}
return strtotime($date);
}
示例9: render
/**
* File type is based on db values table: filetypes
*
*/
public function render($content)
{
$element = $this->getElement();
if (!$element instanceof TA_Form_Element_MagicFile) {
return $content;
}
$view = $element->getView();
if (!$view instanceof Zend_View_Interface) {
// using view helpers, so do nothing if no view present
return $content;
}
$output = null;
if ($file = $element->getTaFile()) {
switch ($type = $file->core_filetype) {
case 'userimage':
$output = '<li><img src="/core/file/' . $file->file_id . '" alt="userimage_' . $file->file_id . '" /></li>';
break;
case 'submission':
$date = new Zend_Date($file->modified, Zend_Date::ISO_8601);
$output = '<li><a title="download paper" href="/core/file/getfile/id/' . $file->file_id . '">' . htmlspecialchars($file->filename_orig) . '</a> (' . $view->timeSince($date->getTimestamp()) . ' ago' . ')</li>';
break;
case 'paper':
$date = new Zend_Date($file->modified, Zend_Date::ISO_8601);
$output = '<li><a title="download paper" href="/core/file/getfile/id/' . $file->file_id . '">' . htmlspecialchars($file->filename_orig) . '</a> (' . $view->timeSince($date->getTimestamp()) . ' ago' . ')</li>';
break;
case 'slides':
$date = new Zend_Date($file->modified, Zend_Date::ISO_8601);
$output = '<li><a title="download slides" href="/core/file/getfile/id/' . $file->file_id . '">' . htmlspecialchars($file->filename_orig) . '</a> (' . $view->timeSince($date->getTimestamp()) . ' ago' . ')</li>';
break;
case 'location':
$date = new Zend_Date($file->modified, Zend_Date::ISO_8601);
$output = '<li><img src="/core/file/' . $file->file_id . '" alt="location_' . $file->file_id . '" />' . '</a> (' . $view->timeSince($date->getTimestamp()) . ' ago' . ')</li>';
break;
case 'misc':
$date = new Zend_Date($file->modified, Zend_Date::ISO_8601);
$output = '<li><a title="download slides" href="/core/file/getfile/id/' . $file->file_id . '">' . htmlspecialchars($file->filename_orig) . '</a> (' . $view->timeSince($date->getTimestamp()) . ' ago' . ')</li>';
break;
default:
$date = new Zend_Date($file->modified, Zend_Date::ISO_8601);
$output = '<li><a title="download file" href="/core/file/getfile/id/' . $file->file_id . '">' . htmlspecialchars($file->filename_orig) . '</a> (' . $view->timeSince($date->getTimestamp()) . ' ago' . ')</li>';
break;
}
}
$placement = $this->getPlacement();
$separator = $this->getSeparator();
switch ($placement) {
case 'PREPEND':
return $output . $separator . $content;
case 'APPEND':
default:
return $content . $separator . $output;
}
}
示例10: getIntervals
public function getIntervals()
{
if (!$this->_intervals) {
$this->_intervals = array();
if (!$this->_from && !$this->_to) {
return $this->_intervals;
}
$dateStart = new Zend_Date($this->_from);
$dateEnd = new Zend_Date($this->_to);
$t = array();
$firstInterval = true;
/** START AITOC FIX **/
if (in_array((string) $this->_period, array('day', 'month', 'year'))) {
/** END AITOC FIX **/
while ($dateStart->compare($dateEnd) <= 0) {
switch ($this->_period) {
case 'day':
$t['title'] = $dateStart->toString(Mage::app()->getLocale()->getDateFormat());
$t['start'] = $dateStart->toString('yyyy-MM-dd HH:mm:ss');
$t['end'] = $dateStart->toString('yyyy-MM-dd 23:59:59');
$dateStart->addDay(1);
break;
case 'month':
$t['title'] = $dateStart->toString('MM/yyyy');
$t['start'] = $firstInterval ? $dateStart->toString('yyyy-MM-dd 00:00:00') : $dateStart->toString('yyyy-MM-01 00:00:00');
$lastInterval = $dateStart->compareMonth($dateEnd->getMonth()) == 0;
$t['end'] = $lastInterval ? $dateStart->setDay($dateEnd->getDay())->toString('yyyy-MM-dd 23:59:59') : $dateStart->toString('yyyy-MM-' . date('t', $dateStart->getTimestamp()) . ' 23:59:59');
$dateStart->addMonth(1);
if ($dateStart->compareMonth($dateEnd->getMonth()) == 0) {
$dateStart->setDay(1);
}
$firstInterval = false;
break;
case 'year':
$t['title'] = $dateStart->toString('yyyy');
$t['start'] = $firstInterval ? $dateStart->toString('yyyy-MM-dd 00:00:00') : $dateStart->toString('yyyy-01-01 00:00:00');
$lastInterval = $dateStart->compareYear($dateEnd->getYear()) == 0;
$t['end'] = $lastInterval ? $dateStart->setMonth($dateEnd->getMonth())->setDay($dateEnd->getDay())->toString('yyyy-MM-dd 23:59:59') : $dateStart->toString('yyyy-12-31 23:59:59');
$dateStart->addYear(1);
if ($dateStart->compareYear($dateEnd->getYear()) == 0) {
$dateStart->setMonth(1)->setDay(1);
}
$firstInterval = false;
break;
}
$this->_intervals[$t['title']] = $t;
}
/** START AITOC FIX **/
}
/** END AITOC FIX **/
}
return $this->_intervals;
}
示例11: getTime
/**
* Imprime a data no formato correto
*
* @param date $d Data a ser impressa
* @param string $format Formato da data
* @param string $locale Localização da data
*
*/
public function getTime($d, $format = null, $locale = null)
{
// Define o formato
if (!isset($format)) {
$format = Zend_Date::ISO_8601;
} elseif ($format == 'twitter') {
$format = 'EEE MMM dd HH:mm:ss ZZZ yyyy';
$locale = 'en_US';
} elseif ($format == 'fb') {
$format = 'EEE, MMM dd yyyy HH:mm:ss ZZZ';
$locale = 'en_US';
}
// Cria a data
$date = new Zend_Date($d, $format, $locale);
$date->setLocale('pt_BR')->setTimezone('America/Sao_Paulo');
if ($date->get('Y') == 0) {
$date->set(date('Y'), 'Y');
}
//echo "<br/><b>$d => " . $date->get('Y') .'</b>';
// Calcula a diferença
$now = time();
$time = $now - $date->getTimestamp();
// Formata a hora
if ($time < 60) {
$time .= ' segundos';
} elseif ($time < 3600) {
//60*60
$time = round(floatval($time) / 60) . ' minutos';
} elseif ($time < 7200) {
//60*60*2
$time = round(floatval($time) / 3660) . ' hora';
} elseif ($time < 86400) {
//60*60*24
$time = round(floatval($time) / 3660) . ' horas';
} elseif ($time < 604800) {
//60*60*24*30
$time = round(floatval($time) / 86400) . ' dias';
} elseif ($time > 1209600 && $time <= 2592000) {
//60*60*24*(7*4)
$time = round(floatval($time) / 604800) . ' semanas';
} elseif ($time > 2592000 && $time <= 5184000) {
//60*60*24*30 && 60*60*24*30*2
$time = round(floatval($time) / 2592000) . ' mês';
} elseif ($time > 5184000 && $time < 31104000) {
//60*60*24*30*2 && 60*60*24*30*12
$time = round(floatval($time) / 2592000) . ' meses';
} else {
//if ($time < 31104000) { //60*60*24*30*12
$time = ' mais de um ano (' . $date->toString() . ')';
}
return $time;
}
示例12: getIntervals
/**
* Retrieve array of intervals
*
* @param string $from
* @param string $to
* @param string $period
* @return array
*/
public function getIntervals($from, $to, $period = self::REPORT_PERIOD_TYPE_DAY)
{
$intervals = array();
if (!$from && !$to) {
return $intervals;
}
$start = new Zend_Date($from, Varien_Date::DATE_INTERNAL_FORMAT);
if ($period == self::REPORT_PERIOD_TYPE_DAY) {
$dateStart = $start;
}
if ($period == self::REPORT_PERIOD_TYPE_MONTH) {
$dateStart = new Zend_Date(date("Y-m", $start->getTimestamp()), Varien_Date::DATE_INTERNAL_FORMAT);
}
if ($period == self::REPORT_PERIOD_TYPE_YEAR) {
$dateStart = new Zend_Date(date("Y", $start->getTimestamp()), Varien_Date::DATE_INTERNAL_FORMAT);
}
$dateEnd = new Zend_Date($to, Varien_Date::DATE_INTERNAL_FORMAT);
while ($dateStart->compare($dateEnd) <= 0) {
switch ($period) {
case self::REPORT_PERIOD_TYPE_DAY:
$t = $dateStart->toString('yyyy-MM-dd');
$dateStart->addDay(1);
break;
case self::REPORT_PERIOD_TYPE_MONTH:
$t = $dateStart->toString('yyyy-MM');
$dateStart->addMonth(1);
break;
case self::REPORT_PERIOD_TYPE_YEAR:
$t = $dateStart->toString('yyyy');
$dateStart->addYear(1);
break;
}
$intervals[] = $t;
}
return $intervals;
}
示例13: _afterSave
protected function _afterSave(Mage_Core_Model_Abstract $object)
{
//insert field values
if (count($object->getData('field')) > 0) {
foreach ($object->getData('field') as $field_id => $value) {
if (is_array($value)) {
$value = implode("\n", $value);
}
$field = Mage::getModel('webforms/fields')->load($field_id);
if (strstr($field->getType(), 'date') && strlen($value) > 0) {
$date = new Zend_Date();
$date->setDate($value, $field->getDateFormat(), Mage::app()->getLocale()->getLocaleCode());
if ($field->getType() == 'datetime') {
$date->setTime($value, $field->getDateFormat(), Mage::app()->getLocale()->getLocaleCode());
}
$value = date($field->getDbDateFormat(), $date->getTimestamp());
}
if ($field->getType() == 'select/contact' && is_numeric($value)) {
$value = $field->getContactValueById($value);
}
if ($value == $field->getHint()) {
$value = '';
}
// create key
$key = "";
if ($field->getType() == 'file' || $field->getType() == 'image') {
$key = Mage::helper('webforms')->randomAlphaNum(6);
if ($object->getData('key_' . $field_id)) {
$key = $object->getData('key_' . $field_id);
}
}
$object->setData('key_' . $field_id, $key);
$select = $this->_getReadAdapter()->select()->from($this->getTable('webforms/results_values'))->where('result_id = ?', $object->getId())->where('field_id = ?', $field_id);
$result_value = $this->_getReadAdapter()->fetchAll($select);
if (!empty($result_value[0])) {
$this->_getWriteAdapter()->update($this->getTable('webforms/results_values'), array("value" => $value, "key" => $key), "id = " . $result_value[0]['id']);
} else {
$this->_getWriteAdapter()->insert($this->getTable('webforms/results_values'), array("result_id" => $object->getId(), "field_id" => $field_id, "value" => $value, "key" => $key));
}
}
}
Mage::dispatchEvent('webforms_result_save', array('result' => $object));
return parent::_afterSave($object);
}
示例14: getIntervals
public function getIntervals()
{
if (!$this->_intervals) {
$this->_intervals = array();
if (!$this->_from && !$this->_to) {
return $this->_intervals;
}
$dateStart = new Zend_Date($this->_from);
$dateStart2 = new Zend_Date($this->_from);
$dateEnd = new Zend_Date($this->_to);
$t = array();
while ($dateStart->compare($dateEnd) <= 0) {
switch ($this->_period) {
case 'day':
$t['title'] = $dateStart->toString(Mage::app()->getLocale()->getDateFormat());
$t['start'] = $dateStart->toString('yyyy-MM-dd HH:mm:ss');
$t['end'] = $dateStart->toString('yyyy-MM-dd 23:59:59');
$dateStart->addDay(1);
break;
case 'month':
$t['title'] = $dateStart->toString('MM/yyyy');
$t['start'] = $dateStart->toString('yyyy-MM-01 00:00:00');
$t['end'] = $dateStart->toString('yyyy-MM-' . date('t', $dateStart->getTimestamp()) . ' 23:59:59');
$dateStart->addMonth(1);
break;
case 'year':
$t['title'] = $dateStart->toString('yyyy');
$t['start'] = $dateStart->toString('yyyy-01-01 00:00:00');
$t['end'] = $dateStart->toString('yyyy-12-31 23:59:59');
$dateStart->addYear(1);
break;
}
$this->_intervals[$t['title']] = $t;
}
if ($this->_period != 'day') {
$titles = array_keys($this->_intervals);
if (count($titles) > 0) {
$this->_intervals[$titles[0]]['start'] = $dateStart2->toString('yyyy-MM-dd 00:00:00');
$this->_intervals[$titles[count($titles) - 1]]['end'] = $dateEnd->toString('yyyy-MM-dd 23:59:59');
}
}
}
return $this->_intervals;
}
示例15: isEditable
function isEditable()
{
$date = new Zend_Date($this->dt . ' ' . $this->tm);
#d($date->getTimestamp());
$seconds = Zx_Db_Table_Comment::EDIT_TIMELIMIT * 60;
$diff = time() - $date->getTimestamp();
return $diff <= $seconds;
/*
$res = $date->compare($seconds, Zend_Date::SECOND);
d($res);
// 0 = equal, 1 = later, -1 = earlier
if ($res > -1) {
return true;
} else {
return false;
}
*/
}