- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
升级到 PHP 5.3 后,我的应用程序返回时间戳类型为“2010-12-15-10.23.22.716000”的 DB2 列。这导致 PHP DateTime 函数出现问题,因为它失败了
$time = new DateTime("2010-12-15-10.23.22.716000");
Failed to parse time string (2010-12-15-10.23.22.716000) at position 25 (0): Unexpected character
DB2 时间戳似乎存在太精确的问题。我可以以某种方式强制连接更改时间戳格式以获取数据吗?
我正在使用 db2_connect 函数连接到数据库,如下所示:
$this->connection = db2_connect ( $config ['dsn'], $config ['username'], $config ['password'] );
编辑:我想使用下面提到的解决方案,但它对我不起作用,并且在我的系统(AS400)上运行很奇怪。我有: $timeRec = DateTime::createFromFormat('Y-m-d-h.i.s.u',$value);
$value = $timeRec->format('Y-m-d H:i:s');
$value = new DibiDateTime($value);
如果我在 ->format 之后执行 var_dump($value) ,则会返回正确的字符串,但如果我尝试将此字符串提供给 DibiDateTime,则会出现:
public function __construct($time = 'now', DateTimeZone $timezone = NULL)
{
if ($timezone === NULL) {
parent::__construct($time);
}
}
然后失败:
function format() on a non-object
即使我之前用 var_dump($timeRec) 检查过是否是正确的 DateTime 对象。
最佳答案
我认为你的函数(无论它是什么)在日期字符串末尾的微秒上令人窒息。使用 DateTime::createFromFormat()
函数通过“u”微秒标签来处理此问题。看到这里http://php.net/manual/en/function.date.php
$time = DateTime::createFromFormat('Y-m-d-h.i.s.u', '2010-12-15-10.23.22.716000');
var_dump($time);
我的系统上的输出:-
object(DateTime)[1]
public 'date' => string '2010-12-15 10:23:22' (length=19)
public 'timezone_type' => int 3
public 'timezone' => string 'UTC' (length=3)
关于php - DB2 时间戳 PHP 日期时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12654051/
给定一个带有多个 date_time 戳的字符串,我想 提取第一个戳及其前面的文本 候选字符串可以有一个或多个时间戳 后续的 date_time 戳记将被 sep="-" 隔开 后续date_time
是否可以合并从相机拍摄的文本和照片?我想在照片上标记日期和时间,但我在 Google 上找不到任何内容。 最佳答案 使用下面的代码来实现你所需要的。 Bitmap src = Bitm
有没有办法通过 Graph API 戳另一个用户?基于this post ,并使用 Graph Explorer ,我发布到“/USERID/pokes”,我已经授予它(Graph API 应用程序和
我有两个向左浮动的元素。一个是 body 的第一个 child ,另一个是容器的第一个 child ,容器是 body 的第二个 child 。 ...
我是一名优秀的程序员,十分优秀!