小编pet*_*cci的帖子

如何使用symfony 3在php中将日期属性设置为当前日期

我在将 datetime 属性设置为当前日期时遇到问题,如果我将其强制设置为当前时间戳,我会收到“对字符串的成员函数 format() 的调用”错误

**here are my getter and setter with some modifications**
public function getDateajout()
{
    date_default_timezone_set('Africa/Tunis');
    $dateajout=date_default_timezone_get();
    return $this->dateajout;
}

public function setDateajout($dateajout)
{

    $this->dateajout =$dateajout;


}
Run Code Online (Sandbox Code Playgroud)

php datetime timestamp symfony

5
推荐指数
1
解决办法
2220
查看次数

Symfony 3 错误:加载的类名和声明的类名之间大小写不匹配

我刚刚遇到这个错误

加载的类名和声明的类名之间的大小写不匹配:MyApp\UserBundle\Entity\post vs MyApp\UserBundle\Entity\Post

我正在使用两个控制器来执行删除和返回旧页面的特定操作

这是我的按钮的代码

<a href="{{ path('DeleteComment',{'idc':comment.id}) }}"></a>
                                <a href="{{ path('DeleteComment',{'idc':comment.id}) }}"> <i
                                            class="icon-trash"></i>Delete</a>
Run Code Online (Sandbox Code Playgroud)

这是我的路由代码:

get_view_post:
path:     /blog/get/one/post/{id}/
defaults: { _controller: "MyAppBlogBundle:Blog:getpost" }
DeleteComment:
path:     /blog/post/comment/delete/{idc}/
defaults: { _controller: "MyAppBlogBundle:Blog:DeleteComment" }
Run Code Online (Sandbox Code Playgroud)

这是我的控制器代码:

public function DeleteCommentAction($idc)
{

    $em = $this->getDoctrine()->getManager();
    $comment = $em->getRepository('MyAppUserBundle:PostComment')->find($idc);
    $idPost =$comment->getIdPost();


    $em->remove($comment);
    $em->flush();


    return $this->redirectToRoute("get_view_post", array('id' => $idPost));
}


 public function getpostAction($id)
{
    $user = $this->getUser();
    $idu = $user->getId();
    $em = $this->getDoctrine()->getManager();
    $em1 = $this->getDoctrine()->getManager();
    $post = $em->getRepository('MyAppUserBundle:Post')->find($id);
    $idPost=$post->getId();
    $comment = $em1->getRepository('MyAppUserBundle:PostComment')->findBy(array('idPost' => $idPost));
    return …
Run Code Online (Sandbox Code Playgroud)

php mismatch symfony

1
推荐指数
1
解决办法
2万
查看次数

标签 统计

php ×2

symfony ×2

datetime ×1

mismatch ×1

timestamp ×1