Retrieve the server time and date as a string and pass it to the txt file


I'm trying to get server date and time and send it to email or write to txt file from simple php form.

here is a sample of code



$upisufajl =  ("\"{$_POST['firstName']}\",\"{$_POST['lastName']}\",\"{$_POST['email']}\",\"{$_POST['company']}\",\"{$_POST['datum']}\",\"{$_POST['oblik']}\",\"{$_POST['kategorija']}\",\"{$_POST['podkategorija']}\",\"{$_POST['message']}\"\n");

when do I need to write insted of {$_POST['datum']} to write date in txt file. everything elese works fine, but it doesnt show date.

echo date("r"); shows date and time correctly. do I need to convert it to string to be able to write it in txt file?

This is because $_POST['datum'] doesn't exist (at least that we can see in this code). It's just $datum.

$upisufajl = ("\"{$_POST['firstName']}\",\"{$_POST['lastName']}\",\"{$_POST['email']}\",\"{$_POST['company']}\",\"{$datum}\",\"{$_POST['oblik']}\",\"{$_POST['kategorija']}\",\"{$_POST['podkategorija']}\",\"{$_POST['message']}\"\n");