本文整理汇总了PHP中Ak::getTimestamp方法的典型用法代码示例。如果您正苦于以下问题:PHP Ak::getTimestamp方法的具体用法?PHP Ak::getTimestamp怎么用?PHP Ak::getTimestamp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ak
的用法示例。
在下文中一共展示了Ak::getTimestamp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Test_for_getTimestamp
public function Test_for_getTimestamp()
{
$this->assertEqual(Ak::getTimestamp(), Ak::time());
$this->assertEqual('17:52:03', Ak::getDate(Ak::getTimestamp('17:52:03'), 'H:i:s'));
$this->assertEqual(date('Y-m-d') . ' 17:52:03', Ak::getDate(Ak::getTimestamp('17:52:03')));
$this->assertEqual('2005-12-25 00:00:00', Ak::getDate(Ak::getTimestamp('2005-12-25')));
$this->assertEqual('1592-10-09 00:00:00', Ak::getDate(Ak::getTimestamp('1592-10-09')));
$this->assertEqual('2192-10-09 00:00:00', Ak::getDate(Ak::getTimestamp('2192-10-09')));
$this->assertEqual('2192-10-09 01:02:03', Ak::getDate(Ak::getTimestamp('2192-10-9 01:02:03')));
}
示例2: test_signed_up
public function test_signed_up()
{
$Expected = $this->new_mail();
$Expected->setTo($this->recipient);
$Expected->setSubject("[Signed up] Welcome {$this->recipient}");
$Expected->setBody("Hello there,\n\nMr. {$this->recipient}");
$Expected->setFrom("system@example.com");
$Expected->setDate(Ak::getTimestamp("2004-12-12"));
$TestMailer = new TestMailer();
$this->assertTrue($Created = $TestMailer->create('signed_up', $this->recipient));
$this->assertEqual($Expected->getEncoded(), $Created->getEncoded());
$this->assertTrue($TestMailer->deliver('signed_up', $this->recipient));
$this->assertTrue(!empty($TestMailer->deliveries[0]));
$this->assertEqual($Expected->getEncoded(), $TestMailer->deliveries[0]);
}
示例3: authenticateWithToken
function authenticateWithToken($token)
{
$options = User::_decodeToken($token);
if (!empty($options) && !empty($options['hash']) && !empty($options['id'])) {
$User = new User();
$User = $User->find($options['id']);
if (!empty($options['expires']) && $options['expires'] < Ak::getTimestamp()) {
return false;
}
if ($options['hash'] == $User->_getTokenHash($options)) {
$User->updateAttribute('last_login_at', Ak::getDate());
return $User;
}
}
return false;
}
示例4: authenticateWithToken
public function authenticateWithToken($token, $update_last_login = true)
{
$options = User::decodeToken($token);
if (!empty($options) && !empty($options['hash']) && !empty($options['id'])) {
$User = new User();
$User = $User->find($options['id']);
if (!empty($options['expires']) && $options['expires'] < Ak::getTimestamp()) {
return false;
}
if ($options['hash'] == $User->getTokenHash($options)) {
if ($update_last_login) {
$User->updateAttribute('last_login_at', Ak::getDate());
}
$this->setCurrentUser($User);
return $User;
}
}
return false;
}
示例5: getToken
/**
* Returns a one time use token for accesing an account.
*
* This might be used for retrieving lost passwords.
*
* Tokens can be validated using the Sentinel::isValidLoginTokenForUser method
*/
function getToken($options = array())
{
$default_options = array('id' => (int) $this->get('id'), 'single_use' => !empty($options['single_use']));
$options = array_merge($default_options, $options);
$options['expires'] = empty($options['expires']) ? 0 : Ak::getTimestamp() + (empty($options['expires']) ? '0' : ($options['expires'] == true ? 86400 : $options['expires']));
$options['single_use'] = $options['single_use'] ? 1 : 0;
$options['hash'] = $this->_getTokenHash($options);
return $this->_encodeToken($options);
}
示例6: locale_date
/**
* Converts an ISO date to current locale format
*
*/
function locale_date($iso_date)
{
$timestamp = Ak::getTimestamp($iso_date);
$format = Ak::locale('date_format');
return Ak::getDate($timestamp, $format);
}
示例7: test_with_relations_json
public function test_with_relations_json()
{
$person = $this->Person->create(array('first_name' => 'Hansi', 'last_name' => 'Müller', 'email' => 'hans@mueller.com'));
$person_created_at = gmdate('Y-m-d\\TH:i:s\\Z', Ak::getTimestamp($person->created_at));
$person->account->create(array('username' => 'hansi', 'password' => 'wilma'));
$account_created_at = gmdate('Y-m-d\\TH:i:s\\Z', Ak::getTimestamp($person->account->created_at));
$expected = <<<EOX
{"id":{$person->id},"first_name":"Hansi","last_name":"M\\u00fcller","email":"hans@mueller.com","created_at":"{$person_created_at}","account":{"id":{$person->account->id},"person_id":{$person->id},"username":"hansi","password":"wilma","is_enabled":0,"credit_limit":null,"firm_id":null,"reset_key":null,"created_at":"{$account_created_at}"}}
EOX;
$json = $person->toJson(array('include' => 'account'));
$this->_compareJson($expected, $json);
$person_reloaded = $person->fromJson($json);
$this->assertEqual($person->first_name, $person_reloaded->first_name);
$this->assertEqual($person->last_name, $person_reloaded->last_name);
$this->assertEqual($person->account->id, $person_reloaded->account->id);
}
示例8: test_should_convert_between_timestamp_and_date
public function test_should_convert_between_timestamp_and_date()
{
$iso_date = '2007-10-15 16:30:00';
$this->assertEqual(Ak::getDate(Ak::getTimestamp($iso_date)), $iso_date);
$this->assertEqual(Ak::getDate(Ak::getTimestamp('2007-10-15 16:30')), $iso_date);
}
示例9: castAttributeForDatabase
function castAttributeForDatabase($column_name, $value, $add_quotes = true)
{
$result = '';
switch ($this->getColumnType($column_name)) {
case 'datetime':
if(!empty($value)){
$date_time = $this->_db->quote_datetime(Ak::getTimestamp($value));
$result = $add_quotes ? $date_time : trim($date_time ,"'");
}else{
$result = 'null';
}
break;
case 'date':
if(!empty($value)){
$date = $this->_db->quote_date(Ak::getTimestamp($value));
$result = $add_quotes ? $date : trim($date, "'");
}else{
$result = 'null';
}
break;
case 'boolean':
$result = is_null($value) ? 'null' : (!empty($value) ? "'1'" : "'0'");
break;
case 'binary':
if($this->_getDatabaseType() == 'postgre'){
$result = is_null($value) ? 'null::bytea ' : " '".$this->_db->escape_blob($value)."'::bytea ";
}else{
$result = is_null($value) ? 'null' : ($add_quotes ? $this->_db->quote_string($value) : $value);
}
break;
case 'decimal':
if(is_null($value)){
$result = 'null';
}else{
if($scale = $this->getColumnScale($column_name)){
$value = number_format($value, $scale, '.', '');
}
$result = $add_quotes ? $this->_db->quote_string($value) : $value;
}
break;
case 'serial':
case 'integer':
$result = (is_null($value) || $value==='') ? 'null' : (integer)$value;
break;
case 'float':
$result = (empty($value) && $value !== 0) ? 'null' : (is_numeric($value) ? $value : $this->_db->quote_string($value));
$result = !empty($this->_columns[$column_name]['notNull']) && $result == 'null' && $this->_getDatabaseType() == 'sqlite' ? '0' : $result;
break;
default:
if($this->_shouldSerializeColumn($column_name)){
$value = serialize($value);
}
$result = is_null($value) ? 'null' : ($add_quotes ? $this->_db->quote_string($value) : $value);
break;
}
// !! nullable vs. not nullable !!
return empty($this->_columns[$column_name]['notNull']) ? ($result === '' ? "''" : $result) : ($result === 'null' ? '' : $result);
}
示例10: _getLogFormatedAsString
function _getLogFormatedAsString($type, $error_number, $error_message, $filename, $line_number, $serialized = false)
{
$message = Ak::getTimestamp() . "\t[{$error_number}]\t{$error_message}";
$params = array_merge($this->_log_params, $this->extended_details ? array('file' => $filename, 'line_number' => $line_number, 'remote_address' => $_SERVER['REMOTE_ADDR'], 'browser' => $_SERVER['HTTP_USER_AGENT']) : array());
if ($serialized) {
$message .= count($params) ? "\t" . serialize($params) : '';
} else {
$details = '';
foreach ($params as $k => $v) {
$details .= "\n\t\t- " . AkInflector::humanize($k) . ": {$v}";
}
$message .= empty($details) ? "\n" : "\n\t" . 'PARAMS{' . $details . "\t\n}\n";
}
return $message;
}
示例11: _saveLogInDatabase
function _saveLogInDatabase($type, $error_mode, $error_message)
{
$db =& Ak::db();
$message = $this->_getLogFormatedAsRawText($type, $error_mode, $error_message);
$sql = 'INSERT INTO log (user_id, type, message, severity, location, hostname, created) ' . " VALUES (0, " . $db->quote_string($type) . ", " . $db->quote_string($message) . ', ' . ($this->mode & AK_MODE_DIE ? 100 : 0) . ', ' . $db->quote_string(AK_CURRENT_URL) . ', ' . $db->quote_string($_SERVER['REMOTE_ADDR']) . ', ' . $db->quote_string(Ak::getTimestamp()) . ');';
if ($db->execute($sql) === false) {
die($this->internalError($this->t('Error inserting: ') . $db->ErrorMsg(), __FILE__, __LINE__));
}
}
示例12: now
/**
* Compute and return the current time, in the time zone represented by
* AkTimeZone.
*/
function now()
{
return $this->adjust(isset($this->_timestamp) ? $this->_timestamp : Ak::getTimestamp());
}
示例13: _getHeaders
function _getHeaders($to = null)
{
return array('From' => trim($this->email_account->sender_name . ' <' . $this->email_account->reply_to . '>'), 'Return-path' => trim($this->email_account->sender_name . ' <' . $this->email_account->reply_to . '>'), 'Subject' => $this->subject, 'To' => $to, 'Message-Id' => '<' . $this->id . '.' . Ak::uuid() . substr('bermi@example.com', strpos('bermi@example.com', '@')) . '>', 'Date' => strftime("%a, %d %b %Y %H:%M:%S %z", Ak::getTimestamp()));
}
示例14: toXml
//.........这里部分代码省略.........
$xml = '';
if (!(isset($options['skip_instruct']) && $options['skip_instruct'] == true)) {
$xml .= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
}
$xml .= $current_padding . '<' . $root . " type=\"array\">\n";
$collection = $options['collection'];
unset($options['collection']);
$options['skip_instruct'] = true;
$options['padding']++;
foreach ($collection as $element) {
$xml .= $element->toXml($options);
}
$xml .= $current_padding . '</' . $root . ">\n";
return $xml;
}
/**
* see if we need to include associations
*/
$associatedIds = array();
if (isset($options['include']) && !empty($options['include'])) {
$options['include'] = is_array($options['include']) ? $options['include'] : preg_split('/,\\s*/', $options['include']);
foreach ($this->_Model->getAssociations() as $key => $obj) {
if (in_array($key, $options['include'])) {
if ($obj->getType() != 'hasAndBelongsToMany') {
$associatedIds[$obj->getAssociationIds() . '_id'] = array('name' => $key, 'type' => $obj->getType());
} else {
$associatedIds[$key] = array('name' => $key, 'type' => $obj->getType());
}
}
}
}
if (isset($options['only'])) {
$options['only'] = is_array($options['only']) ? $options['only'] : preg_split('/,\\s*/', $options['only']);
}
if (isset($options['except'])) {
$options['except'] = is_array($options['except']) ? $options['except'] : preg_split('/,\\s*/', $options['except']);
}
$xml = '';
if (!(isset($options['skip_instruct']) && $options['skip_instruct'] == true)) {
$xml .= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
}
$root = $this->_convertColumnToXmlElement(AkInflector::underscore($this->_Model->getModelName()));
$xml .= $current_padding . '<' . $root . ">\n";
foreach ($this->_Model->getColumns() as $key => $def) {
if (isset($options['except']) && in_array($key, $options['except'])) {
continue;
} else {
if (isset($options['only']) && !in_array($key, $options['only'])) {
continue;
} else {
$columnType = $def['type'];
$elementName = $this->_convertColumnToXmlElement($key);
$xml .= $current_padding . ' <' . $elementName;
$val = $this->_Model->{$key};
if (!in_array($columnType, array('string', 'text', 'serial'))) {
$xml .= ' type="' . $columnType . '"';
if ($columnType == 'boolean') {
$val = $val ? 1 : 0;
}
} elseif ($columnType == 'serial' && is_numeric($val)) {
$xml .= ' type="integer"';
}
if (!empty($val) && in_array($columnType, array('datetime'))) {
// UTC (Coordinated Universal Time) http://www.w3.org/TR/NOTE-datetime
$val = gmdate('Y-m-d\\TH:i:s\\Z', Ak::getTimestamp($val));
}
if (is_null($val)) {
$xml .= ' nil="true"';
}
$xml .= '>' . Ak::utf8($val) . '</' . $elementName . ">\n";
}
}
}
if (isset($options['include'])) {
foreach ($this->_Model->getAssociations() as $key => $val) {
if (in_array($key, $options['include']) || in_array($val, $options['include'])) {
if (is_array($this->_Model->{$key})) {
$associationElement = $key;
$associationElement = AkInflector::underscore(AkInflector::pluralize($associationElement));
$associationElement = $this->_convertColumnToXmlElement($associationElement);
$xml .= $current_padding . '<' . $associationElement . " type=\"array\">\n";
$options['padding']++;
foreach ($this->_Model->{$key} as $el) {
if ($el instanceof AkBaseModel) {
$xml .= $el->toXml(array('skip_instruct' => true));
}
}
$xml .= $current_padding . '</' . $associationElement . ">\n";
} else {
$el = $this->_Model->{$key}->load();
if ($el instanceof AkBaseModel) {
$xml .= $el->toXml(array('skip_instruct' => true));
}
}
}
}
}
$xml .= $current_padding . '</' . $root . ">\n";
return $xml;
}
示例15: getValueForDateColumn
function getValueForDateColumn($column_name, $value)
{
if (!$this->isNewRecord()) {
if (($column_name == 'updated_on' || $column_name == 'updated_at') && empty($value)) {
return null;
}
} elseif (($column_name == 'created_on' || $column_name == 'created_at') && empty($value)) {
return Ak::time();
} elseif ($column_name == 'expires_on' || $column_name == 'expires_at') {
return empty($value) ? Ak::getTimestamp('9999-12-31 23:59:59') : Ak::getTimestamp($value);
}
return Ak::getTimestamp($value);
}