gpt4 book ai didi

symfony - 使用 Nemo/Alice 包导入日期时间

转载 作者:行者123 更新时间:2023-12-02 16:52:07 25 4
gpt4 key购买 nike

我的问题是关于这个 bundle :https://github.com/nelmio/alice 与 Symfony2 的结合。

我有一些固定装置想要加载到我的新网站中,这个 bundle 非常适合。我创建了一些 YML 文件,并将以下 YML 视为我的固定数据:

DateTime (local):
news-date-1:
__construct: ['2014-07-01']

Stef\BVBundle\Entity\Blog:
StefBVBundle-Blog-1:
title: 'A day with blah'
blog: 'e5645646'
image: 'beach.jpg'
author: 'dsyph3r'
tags: 'symfony2, php, paradise, symblog'
created: @news-date-1
updated: @news-date-1
StefBVBundle-Blog-2:
id: 1
title: 'meeeh'
author: dsyph3r
blog: '5rw5425'
image: beach.jpg
tags: 'symfony2, php, paradise, symblog'
created: '2014-07-01T00:00:00+0200'
updated: '2014-07-01T00:00:00+0200'

标有“StefBVBundle-Blog-1”的标签就像一个魅力,它知道“创建”和“更新”是\DateTime 值。

但是“StefBVBundle-Blog-2”会导致错误,因为 Nemo/Alice 包将其视为字符串,而不是日期时间。是否可以内联日期时间部分?

最佳答案

<( )> 中的 PHP 表达式只是传递给 Doctrine,因此这将完成工作:

Stef\BVBundle\Entity\Blog:
StefBVBundle-Blog-2:
created: <(new \DateTime('2014-02-02'))>

关于symfony - 使用 Nemo/Alice 包导入日期时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25409436/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com