【问题标题】:Firestore PHP SDK - How to save date?Firestore PHP SDK - 如何保存日期?
【发布时间】:2021-03-04 18:55:27
【问题描述】:

我尝试在 firestore 中保存日期,但每次都保存为字符串或数字,我需要另存为时间戳

date( 'U', strtotime( '-4 HOUR' ) ); // result something like 1605958160

PHP 示例

$docRef = $db->collection('users')->document('lovelace');
$docRef->set([
    'first' => 'Ada',
    'last' => 'Lovelace',
    'born' => date( 'U', strtotime( '-4 HOUR' ) )
]);

【问题讨论】:

标签: php google-cloud-platform google-cloud-firestore


【解决方案1】:

关注@RiggsFolly提供的信息我在Github Google Cloud Platform How to add timestamp to firestore找到了这条信息

随便用

new DateTime('2000-01-01', new DateTimeZone('America/Sao_Paulo'));

谢谢

【讨论】:

    猜你喜欢
    • 2018-12-18
    • 2018-07-23
    • 1970-01-01
    • 2020-02-09
    • 2015-07-30
    • 2019-04-19
    • 1970-01-01
    • 1970-01-01
    • 2019-12-02
    相关资源
    最近更新 更多