Simple Date PHP Code Explanation

I have been trying to find out this error In my first PHP code execution. Don’t get any solutions but got some theoretical idea how actually everything working to execute the dates.

If the syntax is perfect and the parsing that means the processing engine can read the codes that should be execute instantly to web server.

echo function which is not a function but it sending string data to browser to show the today’s date and the code is echo $todaysdate;

The date function is already built-in and that will do the rest of works automatically and on Dave’s book I read, ”

The date() function is built in to PHP, meaning that you don’t have to write or copy the function into your PHP5 program; it’s simply there for you to use at any time. It’s written in the same way as functions in most languages. It starts with the name of the function followed by parentheses, and inside the parentheses are arguments—the values, expressions, or more functions that resolve to a value which is then used by the date() function to produce the final answer. Take a look at this line from the example program:

$todaysdate = date("m",time()) . "-" . date("d",time()) ."-".
date("Y",time());

The first argument is “m”, signifying to the date() function that you want to know the month. The second argument uses the time() function, which gets the current time. The date() function processes the current time and extracts the month as a two-character value. You can use the date() function again to get the day and year from the time() function.

Thanks to great writter Dave for the great sample plus explation and you can get this book at amazon.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s