Difference between revisions of "Learning PHP (2)"

From Wiki @ Karl Jones dot com
Jump to: navigation, search
(Timestamp)
Line 3: Line 3:
 
== Timestamp ==
 
== Timestamp ==
  
PHP provides the timestamp() function, which returns the time (from the server clock).
+
PHP provides the <code>time()</code> function, which returns the time (from the server clock).
  
 
The time can be formatted and used in a variety of ways.
 
The time can be formatted and used in a variety of ways.
Line 10: Line 10:
  
 
<pre>
 
<pre>
<p><?php echo ; ?></p>
+
<p><?php echo time(); ?></p>
 
</pre>
 
</pre>
  
Line 19: Line 19:
 
Use your browser's View Source or Inspect Element to confirm that the [[web page]]'s [[source code]] contains only HTML, no PHP.
 
Use your browser's View Source or Inspect Element to confirm that the [[web page]]'s [[source code]] contains only HTML, no PHP.
  
See [[PHP timestamp]] for more information.
+
See [[http://php.net/manual/en/function.time.php time]] for more information.
  
 
== Date ==
 
== Date ==

Revision as of 10:51, 3 September 2015

This article contains examples of PHP.

Timestamp

PHP provides the time() function, which returns the time (from the server clock).

The time can be formatted and used in a variety of ways.

Code snippet:

<p><?php echo time(); ?></p>

Observe how the above code snippet mixes HTML with PHP code islands.

View online.

Use your browser's View Source or Inspect Element to confirm that the web page's source code contains only HTML, no PHP.

See [time] for more information.

Date

PHP provides the date() function, which returns date and time.

The date and time can be formatted and used in a variety of ways.

Code snippet:

<p><?php echo date("Y/m/d"); ?></p>
<p><?php echo date("l"); ?></p>

Observe how the above code snippet mixes HTML with PHP code islands.

View online.

Use your browser's View Source or Inspect Element to confirm that the web page's source code contains only HTML, no PHP.

See PHP date for more information.

See Also

External links

Documentation

Tutorials