简体   繁体   中英

How to get current date in codeigniter

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

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

尝试使用这是DateTime的通用格式

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

use php date function

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

will give you the result

What about:

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM