1

これは、Symfony 1.4、およびおそらくphp 5.3、mysql5.1を実行している以前のすべてのバージョンに関するものです。

1970年未満のデータベースに古い日付を保存してから取得すると、それらは自動的に誤った日付に変換されます。

表の例:

id, some_date
1, 1961-09-09

簡単な例。

$record = MyTablePeer::retrieveByPK(1);
echo $record->getSomeDate(); 
//returns: 09/09/61
//Want it to return: 1961-09-09

出力フォーマットはどこから制御されますか?年間全体をデータベースに保存して、日付全体を取得する必要があります。

4

1 に答える 1

4

日付フィールドゲッターには$formatパラメーターがあり、のようにそれを使用します$record->getSomeDate("Y-m-d");

また、これはdocblockが日付アクセサーについて言っていることです:

このアクセサは、UNIXエポック日付でのみ機能します。エポック前後の日付をサポートする必要がある場合は、propel.useDateTimeClassを使用してビルドするか、この列タイプを(非推奨の)「UNIX前」列タイプ(BU_TIMESTAMPやBU_DATEなど)に変更することを検討してください。

@param      string $format The date/time format string (either date()-style or strftime()-style).
             If format is NULL, then the integer unix timestamp will be returned. 
@return     mixed Formatted date/time value as string or (integer) unix timestamp (if format is NULL).

@throws     PropelException - if unable to convert the date/time to timestamp.
于 2010-09-09T21:50:20.870 に答える