- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
仅在一台特定服务器上出现上述错误,但在其他服务器上则没有。假设是php版本问题。这是触发错误的代码:
//get time interval
static function get_interval($now, $post_time){
$datetime1 = new DateTime();
$datetime1->setTimestamp($now);
最后一行导致了问题。关于如何解决这个问题有什么想法吗?
最佳答案
如果您的 PHP 版本低于 5.3,那么您可以使用此类来使用函数“setTimestamp”和“getTimestamp”:
<?php
class MyDateTime extends DateTime
{
public function setTimestamp( $timestamp )
{
$date = getdate( ( int ) $timestamp );
$this->setDate( $date['year'] , $date['mon'] , $date['mday'] );
$this->setTime( $date['hours'] , $date['minutes'] , $date['seconds'] );
}
public function getTimestamp()
{
return $this->format( 'U' );
}
}
$date = new MyDateTime();
$date->setTimestamp( $someTimestamp );
echo $date->format( 'd/m/Y H:i:s' );
?>
关于php - fatal error :调用未定义的方法 DateTime::setTimestamp(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16554714/
我正在使用 javacv读取 mp4 文件和以下代码来查找视频: FFmpegFrameGrabber frameGrabber; [...] frameGrabber.setTimestamp(ti
我正在开发帐户管理系统。目标是将试用期设置到数据库中。我正在将 Timestamp "2015-10-30 22:55:48" 从 jsonObject 获取到 REST 服务中,并使用准备好的语句插
我的这个项目使用的是 MySQL 数据库。但是现在,我想转向 PostgreSQL。除了有一个时间戳类型列的表外,一切正常。 //MedName is varchar, and DateTime is
在我看来,如果我使用 preparedStatement 将它们插入到我的 mariadb 中,毫秒数会被截断。谷歌搜索没有成功,我发现很多类似的问题已经解决或不适用。但是很难相信我是唯一遇到这个问题
仅在一台特定服务器上出现上述错误,但在其他服务器上则没有。假设是php版本问题。这是触发错误的代码: //get time interval static function get_inter
这是代码的最小版本,我花了很多时间才弄清楚为什么它不起作用: Query q = session.createQuery(queryString); q.setTimestamp(0, new jav
我想知道为什么 setTime 方法的行为与 setDate 完全相同,即没有时间的日期,或者将时间设置为 2014-07-01 13:21:01 它设置为 2014-07-01 00:00:00 ?
本文整理了Java中org.mozilla.zest.core.v1.ZestRequest.setTimestamp()方法的一些代码示例,展示了ZestRequest.setTimestamp()
更新:Timestamp 的构造函数的“秒的分数”参数实际上需要纳秒……我猜是百分之一秒,我的低值被四舍五入了。留题引用.... 我正在努力使用 Oracle 的 C++ 库 - OCCI。总结: 创
我是一名优秀的程序员,十分优秀!