duanjiao7440 2013-07-19 03:38
浏览 39

Silverstripe 2.3.1仅将日期字段保存为1970-1-1

When I save an DataObject with a Date field from a form it gets saved as 1970-1-1.

It's a standard

public static $db = array(
  'MyDate' => 'Date'
);

then

$form->saveInto($obj);
$obj->write();

although both stages (saveinto,write) seem to change the value to 1970. I realise this is not much to go on so I guess I'm after suggestions for how to debug it.

it's using the ecommerce and payment modules.

  • 写回答

1条回答 默认 最新

  • duai1683 2013-08-02 03:12
    关注

    The docs (http://api.silverstripe.org/2.4/class-Date.html) state "The field currently supports New Zealand date format (DD/MM/YYYY), or an ISO 8601 formatted date (YYYY-MM-DD)"

    If the date is being saved as epoch default, it is likely that it's being passed in in an incorrect format. This could be due to a locale difference between your server and the date format that the data type expects.

    You'll need to see the format of $obj->MyDate and manipulate it before calling $form->saveInto() so the date is saved in the correct format.

    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路