Note 1: You don't have to know PHP programming to do this tutorial. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Note 2: I assume that your server supports files with .php extension. If not, you won't be able to do this tutorial. For more info on how to install PHP on your PC go to http://www.php.net | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Type exactly like below in Notepad or any other HTML Editor and save it as date.php in your localhost.
You should see the following result: Example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Let's go through the code, anything between and ?> is considered as a php code by the browser. First we are assigning today's date to a variable called $today, then on the next line we are displaying it to the browser. echo is php code to display any data on the browser. As you have noticed already, ("d M Y h:i A") is a date format that we have constructed. d is for displaying day, M is for month, and Y is for year, h is for hour and i is for minute, and finally A is for displaying AM or PM. This is just a one way of displaying the date and time, there are many other forms that you can create yourself. Also there are several different forms of displaying one data, for example you can display the current month as "February" of "Feb" or "02", it is all up to you how you want to display it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Below is the additional php codes for displaying date and time
|
0 Comments:
Post a Comment