[英]How to get date time of a server in yii2 php
Is there any way to GET
the current date and time of the server in YiII
?有没有什么办法
GET
服务器的当前日期和时间YiII
?
One solution I have found is below我发现的一种解决方案如下
'created_at' => new \yii\db\Expression('NOW()'), But I don't know it's correct or not.
Any help would be highly appreciated.任何帮助将不胜感激。
You can get this through php by using date('Ymd h:i:s')
or date($format)
where $format
contains the format in which you want the time.您可以通过 php 使用
date('Ymd h:i:s')
或date($format)
,其中$format
包含您想要的时间格式。 This by default gives you date and time for now.默认情况下,这会为您提供当前的日期和时间。
You can take a look at the manual for the formats to use: http://php.net/manual/en/function.date.php您可以查看使用格式的手册: http : //php.net/manual/en/function.date.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.