views:

83

answers:

3

I'm sending a mail function to myself.

My first line reads 'Order for $name on $date' The $name variable comes from a form the user fills out. I would like the $date variable to be today's date, whatever that is on that day.

How can I make the $date variable show today's date?

+1  A: 

http://us3.php.net/manual/en/function.date.php The date() function does that.

Annath
+1  A: 
$date = date('m/d/Y');

see http://en.php.net/manual/en/function.date.php for the syntax of date()

MartinodF
I'd prefer date('Y-m-d'), so that it's ISO-8601 ;)
dirtside
You have a good point, but that is up to him.For non interational uses I'd go with m/d/Y (d/m/Y really since I'm Italian ;)
MartinodF
A: 

This puts today's date in a string, all ready to be stuck into the DB :).

$todays_date_string = date("Y-m-d H:i:s");
Cannonade