How to get current date in codeigniter

耗尽温柔 提交于 2021-02-07 12:48:18

问题


How to get current date in codeigniter in YY-mm-dd format. I wants to get current date in YY-mm-dd frmat and put this value into input text box


回答1:


You can use the PHP date function.

date('Y-m-d');

Up to my knowledge, there is no separate date function in codeigniter.

EDIT :

But if you want date in this format 13-04-05 [ yy-mm-dd ], Try this

date('y-m-d');

For more date formats, check this link PHP Date Formats




回答2:


Try to use this is a generic format of DateTime

echo date('Y-m-d H:i:s');



回答3:


use php date function

echo date("Y-m-d");

will give you the result




回答4:


What about:

$date = new \Datetime('now');
var_dump($date);



回答5:


Use php date() function, like this echo Date('Y/m/d'); it give you the desired result!




回答6:


if you want the full date:

echo date('Y-m-d');

depends your date structure.

echo date('d-m-Y');

if you want year only, then echo date('Y'); is enough



来源:https://stackoverflow.com/questions/15830364/how-to-get-current-date-in-codeigniter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!