Help - Search - Member List - Calendar
Full Version: date()?
WorkTheWeb Forums > Webmaster Resources > PHP Help
Support our Sponsors!
Ron Eggler @ work
Hi,

why does "$date = date(y-m-d);" return following (with
error_reporting(E_ALL))
Notice: Use of undefined constant y - assumed 'y' in
/srv/www/htdocs/web2/html/php/nospam/pop.php on line 48

Notice: Use of undefined constant m - assumed 'm' in
/srv/www/htdocs/web2/html/php/nospam/pop.php on line 48

Notice: Use of undefined constant d - assumed 'd' in
/srv/www/htdocs/web2/html/php/nospam/pop.php on line 48
and it just writes 0000-00-00, why? :(
Thanks!

Philip Ronan
"Ron Eggler @ work" wrote:

QUOTE
Hi,

why does "$date = date(y-m-d);" return following (with
error_reporting(E_ALL))
Notice: Use of undefined constant y - assumed 'y' in
/srv/www/htdocs/web2/html/php/nospam/pop.php on line 48
... etc...

Because you're supposed to provide this function with a string argument.

Try putting quote marks around it like this:

$date = date("y-m-d");

--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/

Pascual
Philip Ronan skrev:
QUOTE
"Ron Eggler @ work" wrote:


Hi,

why does "$date = date(y-m-d);" return following (with
error_reporting(E_ALL))
Notice: Use of undefined constant y - assumed 'y' in
/srv/www/htdocs/web2/html/php/nospam/pop.php on line 48
... etc...


Because you're supposed to provide this function with a string argument.

Try putting quote marks around it like this:

$date = date("y-m-d");


It is correct that you need to pass a string as the first argument to
date(), but there is not need to use double quote marks as this will
force PHP to parse the string looking for variables et.c.

Philip Ronan
"Pascual" wrote:

QUOTE
It is correct that you need to pass a string as the first argument to
date(), but there is not need to use double quote marks as this will
force PHP to parse the string looking for variables et.c.

Ah yes. Good point :-)

--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/


PHP Help | Linux Help | Web Hosting | Reseller Hosting | SSL Hosting
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2006 Invision Power Services, Inc.