本文整理汇总了PHP中Time::DateTime方法的典型用法代码示例。如果您正苦于以下问题:PHP Time::DateTime方法的具体用法?PHP Time::DateTime怎么用?PHP Time::DateTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Time
的用法示例。
在下文中一共展示了Time::DateTime方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDateTime
/**
* @covers Time::DateTime
*/
public function testDateTime()
{
$this->assertEquals(Time::DateTime(), new Time_DateTime());
$t = new Time_DateTime();
$this->assertEquals(Time::DateTime($t->getTimestamp()), new Time_DateTime($t));
$this->assertEquals(Time::DateTime($t), new Time_DateTime($t));
}
示例2: assign_to_object
public function assign_to_object($form, $object, $name, $data)
{
$d = (int) $form[$name . '_dd'];
//$d = str_pad($d, 2, "0", STR_PAD_LEFT);
$m = (int) $form[$name . '_mm'];
//$m = str_pad($m, 2, "0", STR_PAD_LEFT);
$y = (int) $form[$name . '_yy'];
//$y = str_pad($y, 4, "0", STR_PAD_LEFT);
$object[$name] = Time::DateTime("{$y}-{$m}-{$d}");
}
示例3: retrieve
/**
* @abstract
*
* @param Net_HTTP_Request $request
* @param OpenId_Client $client
*/
public function retrieve(Net_HTTP_Request $request, OpenId_Client $client)
{
$values = array();
$sreg_to_ax = array_flip(self::$ax_to_sreg);
$schema_to_name = array_flip(array_merge($client->optional, $client->required));
$prefix = 'openid.sreg.';
foreach ($request->parameters as $k => $v) {
if (Core_Strings::starts_with($k, $prefix) && ($name = substr($k, strlen($prefix))) && isset($sreg_to_ax[$name])) {
$ax = $sreg_to_ax[$name];
$alias = $schema_to_name[$ax];
$values[$alias] = trim($this->is_date($ax, $v) ? Time::DateTime($v) : urldecode($v));
}
}
return $values;
}
示例4: decode_datetime
/**
* @param $value
*
* @return Time_DateTime
*/
protected function decode_datetime($value)
{
return Time::DateTime($value);
}
示例5: decode_value
public static function decode_value($value)
{
// a -> Array
// n -> Number
// d -> Date
// b -> Boolean
// s -> String
// o -> Object
// e -> Empty (null)
$regexp = "/^(a|n|d|b|s|o|e)\\:(.*)\$/";
preg_match($regexp, rawurldecode($value), $matches);
if (empty($matches) || empty($matches[1])) {
return;
// non state
}
$type = $matches[1];
$value = $matches[2];
switch ($type) {
case 'e':
return null;
case 'n':
return (double) $value;
case 'd':
return Time::DateTime($value);
case 'b':
return $value == '1';
case 'a':
$all = array();
if ($value != '') {
$split = explode('^', $value);
foreach ($split as $val) {
$all[] = self::decode_value($val);
}
}
return $all;
case 'o':
$all = array();
if ($value != '') {
$split = explode('^', $value);
if (!empty($split)) {
foreach ($split as $val) {
$keyVal = explode('=', $val);
$all[$keyVal[0]] = self::decode_value($keyVal[1]);
}
}
}
return $all;
default:
return $value;
}
}
示例6: get
/**
* Возвращает значение произвольного свойства с преобразованием типов и имен
*
* @param string $query
* @param DOMElement $element
* @param int $index
*
* @return mixed
*/
public function get($query, DOMElement $element, $index = 0)
{
if ($this->has_child_nodes_for($e = $this->xpath($query, $element, $index))) {
return $e;
}
return ($r = $this->node_value_for($e)) && Core_Strings::ends_with($query, 'ed') ? Time::DateTime($r) : $r;
}
示例7: __get
/**
* @param string $property
*
* @return mixed
*/
public function __get($property)
{
if (!isset($this->values[$property])) {
throw new Core_MissingPropertyException($property);
}
switch (true) {
case is_array($this->values[$property]):
return new self($this->values[$property]);
case $this->is_date($property):
return Time::DateTime($this->values[$property]);
default:
return $this->values[$property];
}
}
示例8: testAs_rfc1123
/**
* @covers Time_DateTime::as_rfc1123
*/
public function testAs_rfc1123()
{
$d = '2011-09-11 12:10:11';
$rfc1123 = 'Sun, 11 Sep 2011 12:10:11 +0400';
$this->object = Time::DateTime($d);
$this->assertEquals($rfc1123, $this->object->as_rfc1123());
}
示例9: get_min
/**
* @return Time_DateTime
*/
protected function get_min()
{
return Time::DateTime($this->attrs['min']);
}
示例10: datetime_add
/**
* Суммирует дату/время с секундами
*
* @params string $datetime
* @params integer $sec
*
* @return string|false
*/
static function datetime_add($datetime, $sec)
{
$date = Time::DateTime($datetime);
if (!$date) {
return false;
}
$date->add($sec);
return $date->as_string();
}
示例11: cast_column
/**
* Преобразует значение полученное из БД в нужный формат, для работы с ним в php
*
* @param DB_ColumnMeta $metadata
* @param $value
*
* @return mixed
*/
public function cast_column(DB_ColumnMeta $metadata, $value)
{
switch ($metadata->type) {
case 91:
case 93:
case -2:
return is_null($value) ? null : Time::DateTime($value);
case -5:
case 4:
case 5:
case -6:
case 2:
return (int) $value;
case 6:
case 7:
return (double) $value;
case 1:
case -8:
case -10:
case -9:
case -1:
case 12:
return DB_Adapter_MSSQL::option('convert') ? iconv(DB_Adapter_MSSQL::option('server_charset'), DB_Adapter_MSSQL::option('client_charset'), $value) : $value;
default:
return $value;
}
}
示例12: strftime
/**
* Возвращает отформатированную строку, подставляя дату в нужном формате
*
* @param string $format
* @param Time_DateTime|int|string $date
* @param int $variant
*
* @return string
*/
public function strftime($format, $date, $variant = L10N::FULL)
{
if (!($date = Time::DateTime($date))) {
throw new Core_InvalidArgumentTypeException('date', $date);
}
return strftime(preg_replace(array('/%a/', '/%A/', '/%b/', '/%d([^%]*)%B/', '/%e([^%]*)%B/', '/%B/'), array($this->variant(L10N::ABBREVIATED, 'weekdays', $date->wday), $this->variant(L10N::FULL, 'weekdays', $date->wday), $this->variant(L10N::ABBREVIATED, 'months', $date->month), sprintf('%02d\\1%s', $date->day, $this->variant(L10N::INFLECTED, 'months', $date->month)), sprintf('%d\\1%s', $date->day, $this->variant(L10N::INFLECTED, 'months', $date->month)), $this->variant($variant, 'months', $date->month)), $format), $date->timestamp);
}
示例13: __construct
/**
* Конструктор
*
* @param $object
*/
public function __construct($object)
{
if (!($stat = Core_Types::is_resource($object) ? @fstat($object) : @stat((string) $object))) {
throw new IO_FS_StatException($object);
}
foreach ($stat as $k => $v) {
switch ($k) {
case 'atime':
case 'mtime':
case 'ctime':
$this->stat[$k] = Time::DateTime($v);
break;
default:
$this->stat[$k] = $v;
}
}
}