Combining date with string in php

I try to attach data and time with a file name, but it does not work without errors:

$date = date('Y/m/d H:i:s');
$pdf = $date.'order_sheet.pdf';

The file did not load using this code

+3
source share
3 answers

You use slashes and spaces in the file name, this is not a good idea. Try replacing them with another char, for example:

$date = date('Y_m_d-H-i-s');
+4
source

it will have special characters and a space in the file name, which is not allowed. This may be the reason. You must use a timestamp instead of a date and time.

0
source

you cannot use / in file name

0
source

All Articles