$date = new DateTime();
$timestamp = $date->getTimestamp();xgcalendar,一个日历中有这么两句,但是,getTimestamp()在php5.3中才可以用,求替代的方法

解决方案 »

  1.   


    不行啊,有些地方不对啊
    http://code.google.com/p/xgcalendar/
      

  2.   

    <?php
       date_default_timezone_set('Asia/Shanghai');
       $timestamp=time();
    ?>或者
    <?php
      date_default_timezone_set('Asia/Shanghai');
      $date="2011-08-13 12:00:00";
      $timestamp=strtotime($date);
    ?>
      

  3.   

    http://code.google.com/p/xgcalendar/这是源程序存放的地址,有php5.2.x 的可以下载下来调试一下,谢谢了
      

  4.   

    这个问题我这几天也遇到了,你可以换新版的php,或者参考
    http://www.php.net/manual/zh/datetime.gettimestamp.php
    上的文档说明。里面有讲在php5.2下如何处理的 。
    以下摘自文档:
    注释
    Using U as the parameter to DateTime::format() is an alternative when using PHP 5.2. 
    例子:
    <?php
    $date = new DateTime("1899-12-31");
    // "-2209078800"
    echo $date->format("U");
    // false
    echo $date->getTimestamp();
    ?>
    总的来说就是使用 $date->$date->format("U");代替$date->getTimestamp();
    我在xgcalendar上更改了就可以运行了。
      

  5.   

    根据官方的说法:对于php<=5.2的
    Using U as the parameter to DateTime::format()  is an alternative when using PHP 5.2.也就是用$date = new DateTime("1899-12-31");
            $timestamp=$date->format("U");
    代替原来的$date->getTimestamp();即可