K.K Patel K.K Patel - 6 months ago 19
PHP Question

Declare Variable in PHP Script

In my PHP script following variable creates random filename.
I want to keep file name as

jstack-<date.time>
.log

$jstack_file = trim(`mktemp`);


How can I do that?

Thanks in Advance.

Answer

Try with -

$filename = "jstack-" .time(). ".log";

Or if you need some particular datetime format -

$filename = "jstack-" .date('dmyHis'). ".log";