dongqiao2077 2013-04-29 18:51
浏览 21
已采纳

添加分钟(时间)到目前为止

I am storing appointments by adding 15 minutes to current date as default appointment duration and trying to add Minutes to a date obtained by following code:

$curr_date=new DateTime(date("Y-m-d H:i:s"));--Obtained the current date and time.
$curr_date->add(new DateInterval('P15M'));--Adding 15 minutes

But when I save the Model it throws error saying:

Object of class DateTime could not be converted to string

Any help would be greatly appreciated.

  • 写回答

1条回答 默认 最新

  • douaoj0994 2013-04-29 19:01
    关注

    You'll need to format the date so the SQL query if generated the right way. Use format when you put value into your model.

    $my_model->myattribute = $curr_date->format('Y-m-d H:i:s');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 ansys fluent计算闪退
  • ¥15 有关wireshark抓包的问题
  • ¥15 需要写计算过程,不要写代码,求解答,数据都在图上
  • ¥15 向数据表用newid方式插入GUID问题
  • ¥15 multisim电路设计
  • ¥20 用keil,写代码解决两个问题,用库函数
  • ¥50 ID中开关量采样信号通道、以及程序流程的设计
  • ¥15 U-Mamba/nnunetv2固定随机数种子
  • ¥15 vba使用jmail发送邮件正文里面怎么加图片
  • ¥15 vb6.0如何向数据库中添加自动生成的字段数据。