当前位置: 首页>>代码示例>>PHP>>正文


PHP Date::fromString方法代码示例

本文整理汇总了PHP中Date::fromString方法的典型用法代码示例。如果您正苦于以下问题:PHP Date::fromString方法的具体用法?PHP Date::fromString怎么用?PHP Date::fromString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Date的用法示例。


在下文中一共展示了Date::fromString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: next

 /**
  * Iterator function. Returns a rowset if called without parameter,
  * the fields contents if a field is specified or FALSE to indicate
  * no more rows are available.
  *
  * @param   string field default NULL
  * @return  var
  */
 public function next($field = NULL)
 {
     if (!is_resource($this->handle) || FALSE === ($row = sqlite_fetch_array($this->handle, SQLITE_ASSOC))) {
         return FALSE;
     }
     foreach (array_keys($row) as $key) {
         if (NULL === $row[$key] || !isset($this->fields[$key])) {
             continue;
         }
         switch ($row[$key][0]) {
             case "":
                 $row[$key] = Date::fromString(substr($row[$key], 1));
                 break;
             case "":
                 $row[$key] = intval(substr($row[$key], 1));
                 break;
             case "":
                 $row[$key] = floatval(substr($row[$key], 1));
                 break;
         }
     }
     if ($field) {
         return $row[$field];
     } else {
         return $row;
     }
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:35,代码来源:SQLiteResultSet.class.php

示例2: next

 /**
  * Iterator function. Returns a rowset if called without parameter,
  * the fields contents if a field is specified or FALSE to indicate
  * no more rows are available.
  *
  * @param   string field default NULL
  * @return  var
  */
 public function next($field = NULL)
 {
     if (!is_resource($this->handle) || FALSE === ($row = pg_fetch_assoc($this->handle))) {
         return FALSE;
     }
     foreach (array_keys($row) as $key) {
         switch ($this->fields[$key]) {
             case 'date':
             case 'time':
             case 'timestamp':
                 $row[$key] = Date::fromString($row[$key], $this->tz);
                 break;
             case 'bool':
                 settype($row[$key], 'bool');
                 break;
             case 'int2':
             case 'int4':
             case 'int8':
                 settype($row[$key], 'integer');
                 break;
             case 'float4':
             case 'float8':
             case 'numeric':
                 settype($row[$key], 'double');
                 break;
         }
     }
     if ($field) {
         return $row[$field];
     } else {
         return $row;
     }
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:41,代码来源:PostgreSQLResultSet.class.php

示例3: testSerialization

 public function testSerialization()
 {
     $msg = new XPSoapMessage();
     $msg->createCall('Test', 'testSerialization');
     $this->assertEquals('Test', $msg->action);
     $this->assertEquals('testSerialization', $msg->method);
     $this->assertEquals('SOAP-ENV:Envelope', $msg->root()->getName());
     $this->assertNotEmpty($msg->root()->getAttributes());
     $msg->setData(array('int' => 1, 'float' => 6.1, 'string' => 'Binford', 'string2' => '"<&>"', 'bool' => TRUE, 'date' => Date::fromString('1977-12-14 11:55AM Europe/Berlin'), 'null' => NULL, 'array' => array(2, 3), 'hash' => array('class' => 'Test', 'method' => 'testSerialization')));
     // Let's be somewhat forgiving on whitespace
     $src = trim(chop($msg->getSource(0)));
     $this->assertEquals('<SOAP-ENV:Envelope', substr($src, 0, 18));
     $this->assertEquals('</SOAP-ENV:Envelope>', substr($src, -20));
     $this->assertContains($src, '<int xsi:type="xsd:int">1</int>', 'integer');
     $this->assertContains($src, '<float xsi:type="xsd:float">6.1</float>', 'float');
     $this->assertContains($src, '<string xsi:type="xsd:string">Binford</string>', 'string');
     $this->assertContains($src, '<string2 xsi:type="xsd:string">&quot;&lt;&amp;&gt;&quot;</string2>', 'escaping');
     $this->assertContains($src, '<bool xsi:type="xsd:boolean">true</bool>', 'bool');
     $this->assertContains($src, '<date xsi:type="xsd:dateTime">1977-12-14T11:55:00+01:00</date>', 'date');
     $this->assertContains($src, '<null xsi:nil="true"/>', 'null');
     $this->assertContains($src, '<array xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:anyType[2]">', 'array');
     $this->assertContains($src, '<item xsi:type="xsd:int">2</item>', 'array.inner');
     $this->assertContains($src, '<item xsi:type="xsd:int">3</item>', 'array.inner');
     $this->assertContains($src, '<hash xsi:type="xsd:struct">', 'hash');
     $this->assertContains($src, '<class xsi:type="xsd:string">Test</class>', 'hash.inner');
     $this->assertContains($src, '<method xsi:type="xsd:string">testSerialization</method>', 'hash.inner');
     return $src;
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:28,代码来源:SoapTest.class.php

示例4: next

 /**
  * Iterator function. Returns a rowset if called without parameter,
  * the fields contents if a field is specified or FALSE to indicate
  * no more rows are available.
  *
  * @param   string field default NULL
  * @return  var
  */
 public function next($field = NULL)
 {
     if (!$this->handle instanceof SQLite3Result || FALSE === ($row = $this->handle->fetchArray(SQLITE3_ASSOC))) {
         return FALSE;
     }
     foreach ($row as $key => $value) {
         if (NULL === $value || !isset($this->fields[$key])) {
             continue;
         }
         switch ($value[0]) {
             case "":
                 $row[$key] = Date::fromString(substr($value, 1));
                 break;
             case "":
                 $row[$key] = intval(substr($value, 1));
                 break;
             case "":
                 $row[$key] = floatval(substr($value, 1));
                 break;
         }
     }
     if ($field) {
         return $value;
     } else {
         return $row;
     }
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:35,代码来源:SQLite3ResultSet.class.php

示例5: next

 /**
  * Iterator function. Returns a rowset if called without parameter,
  * the fields contents if a field is specified or FALSE to indicate
  * no more rows are available.
  *
  * @param   string field default NULL
  * @return  var
  */
 public function next($field = NULL)
 {
     if (!is_resource($this->handle) || FALSE === ($row = mssql_fetch_assoc($this->handle))) {
         return FALSE;
     }
     foreach ($row as $key => $value) {
         if (NULL === $value || !isset($this->fields[$key])) {
             continue;
         }
         switch ($this->fields[$key]) {
             case 'datetime':
                 $row[$key] = Date::fromString($value, $this->tz);
                 break;
             case 'numeric':
                 if (FALSE !== strpos($value, '.')) {
                     settype($row[$key], 'double');
                     break;
                 }
                 // Fallthrough intentional
             case 'int':
                 if ($value <= LONG_MAX && $value >= LONG_MIN) {
                     settype($row[$key], 'integer');
                 } else {
                     settype($row[$key], 'double');
                 }
                 break;
         }
     }
     if ($field) {
         return $row[$field];
     } else {
         return $row;
     }
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:42,代码来源:MsSQLResultSet.class.php

示例6: setUp

 /**
  * Set up this test
  *
  */
 public function setUp()
 {
     $this->tz = date_default_timezone_get();
     date_default_timezone_set('GMT');
     $this->nowTime = time();
     $this->nowDate = new Date($this->nowTime);
     $this->refDate = Date::fromString('1977-12-14 11:55');
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:12,代码来源:CalendarTest.class.php

示例7: orderDateParamInfo

 public function orderDateParamInfo()
 {
     $this->assertEquals(OCCURRENCE_OPTIONAL, $this->wrapper->getParamInfo('orderdate', PARAM_OCCURRENCE));
     $this->assertEquals(Date::fromString('1977-12-14'), $this->wrapper->getParamInfo('orderdate', PARAM_DEFAULT));
     $this->assertEquals(NULL, $this->wrapper->getParamInfo('orderdate', PARAM_PRECHECK));
     $this->assertEquals(NULL, $this->wrapper->getParamInfo('orderdate', PARAM_POSTCHECK));
     $this->assertEquals('core:string', $this->wrapper->getParamInfo('orderdate', PARAM_TYPE));
     $this->assertEquals(array(), $this->wrapper->getParamInfo('orderdate', PARAM_VALUES));
     $this->assertClass($this->wrapper->getParamInfo('orderdate', PARAM_CASTER), 'scriptlet.xml.workflow.casters.ToDate');
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:10,代码来源:WrapperTest.class.php

示例8: test_from_string

 /**
  * Test instance creation from a string.
  * 
  */
 function test_from_string()
 {
     $date = Date::withYearMonthDay(2005, 8, 20);
     $this->assertTrue($date->isEqualTo(Date::fromString('2005-08-20')));
     $this->assertTrue($date->isEqualTo(Date::fromString('2005-08-20T15:25:10')));
     $this->assertTrue($date->isEqualTo(Date::fromString('20050820152510')));
     $this->assertTrue($date->isEqualTo(Date::fromString('08/20/2005')));
     $this->assertTrue($date->isEqualTo(Date::fromString('August 20, 2005')));
     $this->assertTrue($date->isEqualTo(Date::fromString('20aug05')));
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:14,代码来源:DateTestCase.class.php

示例9: next

 /**
  * Iterator function. Returns a rowset if called without parameter,
  * the fields contents if a field is specified or FALSE to indicate
  * no more rows are available.
  *
  * @param   string field default NULL
  * @return  var
  */
 public function next($field = NULL)
 {
     if (!is_resource($this->handle) || FALSE === ($row = sybase_fetch_assoc($this->handle))) {
         return FALSE;
     }
     foreach (array_keys($row) as $key) {
         if (NULL === $row[$key] || !isset($this->fields[$key])) {
             continue;
         }
         if ('datetime' === $this->fields[$key]) {
             $row[$key] = Date::fromString($row[$key], $this->tz);
         }
     }
     if ($field) {
         return $row[$field];
     } else {
         return $row;
     }
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:27,代码来源:SybaseResultSet.class.php

示例10: next

 /**
  * Iterator function. Returns a rowset if called without parameter,
  * the fields contents if a field is specified or FALSE to indicate
  * no more rows are available.
  *
  * @param   string field default NULL
  * @return  var
  */
 public function next($field = NULL)
 {
     if (!is_object($this->handle) || NULL === ($row = mysqli_fetch_assoc($this->handle))) {
         return FALSE;
     }
     foreach (array_keys($row) as $key) {
         if (NULL === $row[$key] || !isset($this->fields[$key])) {
             continue;
         }
         switch ($this->fields[$key]) {
             case MYSQLI_TYPE_DATETIME:
             case MYSQLI_TYPE_DATE:
             case MYSQLI_TYPE_TIME:
             case MYSQLI_TYPE_TIMESTAMP:
             case MYSQLI_TYPE_NEWDATE:
                 $row[$key] = '0000-00-00 00:00:00' === $row[$key] ? NULL : Date::fromString($row[$key], $this->tz);
                 break;
             case MYSQLI_TYPE_LONGLONG:
             case MYSQLI_TYPE_LONG:
             case MYSQLI_TYPE_INT24:
             case MYSQLI_TYPE_SHORT:
             case MYSQLI_TYPE_TINY:
             case MYSQLI_TYPE_BIT:
                 if ($row[$key] <= LONG_MAX && $row[$key] >= LONG_MIN) {
                     settype($row[$key], 'integer');
                 } else {
                     settype($row[$key], 'double');
                 }
                 break;
             case MYSQLI_TYPE_FLOAT:
             case MYSQLI_TYPE_DOUBLE:
             case MYSQLI_TYPE_DECIMAL:
             case MYSQLI_TYPE_NEWDECIMAL:
                 settype($row[$key], 'double');
                 break;
         }
     }
     if ($field) {
         return $row[$field];
     } else {
         return $row;
     }
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:51,代码来源:MySQLiResultSet.class.php

示例11: next

 /**
  * Iterator function. Returns a rowset if called without parameter,
  * the fields contents if a field is specified or FALSE to indicate
  * no more rows are available.
  *
  * @param   string field default NULL
  * @return  var
  */
 public function next($field = NULL)
 {
     if (!is_resource($this->handle) || FALSE === ($row = mysql_fetch_assoc($this->handle))) {
         return FALSE;
     }
     foreach (array_keys($row) as $key) {
         if (NULL === $row[$key] || !isset($this->fields[$key])) {
             continue;
         }
         switch ($this->fields[$key]) {
             case 'timestamp':
                 if (strlen($row[$key]) == 14) {
                     $time = sscanf((string) $row[$key], '%04s%02s%02s%02s%02s%02s');
                     $row[$key] = new Date(mktime($time[3], $time[4], $time[5], $time[1], $time[2], $time[0]), $this->tz);
                     break;
                 }
             case 'datetime':
             case 'date':
                 $row[$key] = Date::fromString($row[$key], $this->tz);
                 break;
             case 'int':
                 if ($row[$key] <= LONG_MAX && $row[$key] >= LONG_MIN) {
                     settype($row[$key], 'integer');
                 } else {
                     settype($row[$key], 'double');
                 }
                 break;
             case 'bit':
                 settype($row[$key], 'integer');
                 break;
             case 'real':
                 settype($row[$key], 'double');
                 break;
         }
     }
     if ($field) {
         return $row[$field];
     } else {
         return $row;
     }
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:49,代码来源:MySQLResultSet.class.php

示例12: convert

 public function convert($v, $type)
 {
     if ($v === null) {
         return $v;
     }
     switch ($type) {
         case "int":
         case "year":
             return intval($v);
             break;
         case "real":
             return floatval($v);
             break;
         case "datetime":
         case "date":
             return Date::fromString($v);
             break;
         default:
             return $v;
             break;
     }
 }
开发者ID:marcdraco,项目名称:Webrathea,代码行数:22,代码来源:MysqlResultSet.class.php

示例13: convert

 static function convert($v, $type)
 {
     if ($v === null) {
         return $v;
     }
     switch ($type) {
         case "bool":
             return (bool) $v;
             break;
         case "int":
             return intval($v);
             break;
         case "float":
             return floatval($v);
             break;
         case "date":
             return Date::fromString($v);
             break;
         default:
             return $v;
             break;
     }
 }
开发者ID:adrianmm44,项目名称:zcale,代码行数:23,代码来源:TypeStrategy.class.php

示例14: unserialize


//.........这里部分代码省略.........
         case 113:
             $h1 = new haxe_ds_IntMap();
             $this->cache->push($h1);
             $buf3 = $this->buf;
             $c2 = null;
             $p3 = $this->pos++;
             $c2 = ord(substr($this->buf, $p3, 1));
             while ($c2 === 58) {
                 $i = $this->readDigits();
                 $h1->set($i, $this->unserialize());
                 $p4 = $this->pos++;
                 $c2 = ord(substr($this->buf, $p4, 1));
                 unset($p4);
                 unset($i);
             }
             if ($c2 !== 104) {
                 throw new HException("Invalid IntMap format");
             }
             return $h1;
             break;
         case 77:
             $h2 = new haxe_ds_ObjectMap();
             $this->cache->push($h2);
             $buf4 = $this->buf;
             while (ord(substr($this->buf, $this->pos, 1)) !== 104) {
                 $s2 = $this->unserialize();
                 $h2->set($s2, $this->unserialize());
                 unset($s2);
             }
             $this->pos++;
             return $h2;
             break;
         case 118:
             $d = Date::fromString(_hx_substr($this->buf, $this->pos, 19));
             $this->cache->push($d);
             $this->pos += 19;
             return $d;
             break;
         case 115:
             $len1 = $this->readDigits();
             $buf5 = $this->buf;
             if (haxe_Unserializer_4($this, $_g, $buf5, $len1) !== 58 || $this->length - $this->pos < $len1) {
                 throw new HException("Invalid bytes length");
             }
             $codes = haxe_Unserializer::$CODES;
             if ($codes === null) {
                 $codes = haxe_Unserializer::initCodes();
                 haxe_Unserializer::$CODES = $codes;
             }
             $i1 = $this->pos;
             $rest = $len1 & 3;
             $size = null;
             $size = ($len1 >> 2) * 3 + haxe_Unserializer_5($this, $_g, $buf5, $codes, $i1, $len1, $rest, $size);
             $max = $i1 + ($len1 - $rest);
             $bytes = haxe_io_Bytes::alloc($size);
             $bpos = 0;
             while ($i1 < $max) {
                 $c11 = $codes[haxe_Unserializer_6($this, $_g, $bpos, $buf5, $bytes, $codes, $i1, $len1, $max, $rest, $size)];
                 $c21 = $codes[haxe_Unserializer_7($this, $_g, $bpos, $buf5, $bytes, $c11, $codes, $i1, $len1, $max, $rest, $size)];
                 $pos = $bpos++;
                 $bytes->b[$pos] = chr($c11 << 2 | $c21 >> 4);
                 unset($pos);
                 $c3 = $codes[haxe_Unserializer_8($this, $_g, $bpos, $buf5, $bytes, $c11, $c21, $codes, $i1, $len1, $max, $rest, $size)];
                 $pos1 = $bpos++;
                 $bytes->b[$pos1] = chr($c21 << 4 | $c3 >> 2);
                 unset($pos1);
开发者ID:marcdraco,项目名称:Webrathea,代码行数:67,代码来源:Unserializer.class.php

示例15: addEmptyDates

 /**
  * Add in empty data arrays for dates with no values
  * 
  * @param string $upcoming
  * @return void
  * @access private
  * @since 2/29/08
  */
 private function addEmptyDates($upcoming)
 {
     if (!count($this->data['labels'])) {
         return;
     }
     $i = Date::fromString(end($this->data['labels']))->plus(Duration::withDays(1));
     $upcoming = Date::fromString($upcoming);
     while ($i->isLessThan($upcoming)) {
         $this->data['labels'][] = $i->yyyymmddString();
         $this->data['comments'][] = 0;
         $this->data['edits'][] = 0;
         $this->data['files'][] = 0;
         $this->data['logins'][] = 0;
         $this->data['users'][] = 0;
         $this->data['errors'][] = 0;
         $i = $i->plus(Duration::withDays(1));
     }
 }
开发者ID:adamfranco,项目名称:segue,代码行数:26,代码来源:usage_graph.act.php


注:本文中的Date::fromString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。