Tuesday 26 January 2010

How to use Date function in PHP

Hey guys in this post I am gonna talk about using Date function.

By the way, anything ending with the brackets sign indicates that this is a function. for example Myfunction()

And I was talking about the Date function or Date() it expects the argument you pass it to be a format string, representing the style of output you would like. Each letter in the string represents one part of the date and time. H is the hour in a 24-hour format with leading zeros where required, i is the minutes with a leading zero where required, j is the day of the month without a leading zero, S represents the ordinal suffix (in this case th), and F is the full name of the month.

This is how it looks like when we have entered the required parameters ( or arguments):
date('H:i, jS F')

Cheers!

Using PHP tag in PHP file

We can always use the tag:

< ? php
echo '

This is a PHP tag

';
? >

This is a PHP tag and this goes inside a .PHP file extension.