Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to add word wrap in php date() [duplicate]

I need to print result of function date('d-m-y H:i:s', $time) on two lines like this:

26-11-2019 
10:00:02

I try to add <br/> between 'd-m-y' AND 'H:i:s' doesn't help.

like image 990
mdBender Avatar asked Nov 27 '19 05:11

mdBender


1 Answers

Try this:

echo nl2br(date("d-m-y\nH:i:s", $time));

Note that I used double quotes instead of single quotes. This is because \n won't work with single quotes. For your reference: https://www.php.net/manual/en/function.nl2br.php What is the difference between single-quoted and double-quoted strings in PHP?

like image 197
Arsi Avatar answered Nov 15 '22 00:11

Arsi