laravel5把created_at转成自己想要的格式

不言
Release: 2023-02-28 12:04:01
Original
3214 people have browsed it

$created_at = "2015-12-15 12:00:00"
Copy after login
Copy after login

然后在模版中用 $created_at->format('Y.m.d')是可以的,和input type=datetime-local配合使用就出现了一个小疑问,input type=datetime-local的value必须是2015-12-15T12:00:00
我用format('Y-m-dTH:i:s')就变成了2015-12-15 UTC 12:00:00 ,中间的T会被改成UTC,求解

回复内容:

$created_at = "2015-12-15 12:00:00"
Copy after login
Copy after login

然后在模版中用 $created_at->format('Y.m.d')是可以的,和input type=datetime-local配合使用就出现了一个小疑问,input type=datetime-local的value必须是2015-12-15T12:00:00
我用format('Y-m-dTH:i:s')就变成了2015-12-15 UTC 12:00:00 ,中间的T会被改成UTC,求解

正解
$created_at->format('Y-m-d\TH:i:s')

format('Y-m-d H:i:s')这样试试

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!