Date Function :

1. date() :
Syntax string date ( string $format [, int $timestamp = time() ] )
It return a string formatted date.
example :

date("d");

Explanation :

Finding the current Day of the month, 2 digits with leading zeros.

  	
	<?php
	    $absolute = date("d");
	    print $absolute;
	?>
    
Output :
21

Other Parameters are used in the date function
format characterDescriptionExample returned values
-------------------------------------------------
Day
d Day of the month, 2 digits with leading zeros 01 to 31
D A textual representation of a day, three letters Mon through Sun
l (lowercase 'L') A full textual representation of the day of the week Sunday through Saturday
S English ordinal suffix for the day of the month, 2 characters st, nd, rd or th
Month
m Numeric representation of a month, with leading zeros 01 through 12
M A short textual representation of a month, three letters Jan through Dec
Year
Y A full numeric representation of a year, 4 digits Examples: 1999 or 2009
y A two digit representation of a year Examples: 99 or 09
Time
a Lowercase Ante meridiem and Post meridiem am or pm
A Uppercase Ante meridiem and Post meridiem AM or PM
g 12-hour format of an hour without leading zeros 1 through 12
h 12-hour format of an hour with leading zeros 01 through 12
i Minutes with leading zeros 00 to 59
s Seconds, with leading zeros 00 through 59

2. getdate() :
Syntax array getdate();
Its return type is an associative array.
example:

getdate();

Explanation:

Returns an associative array containing the date information of the timestamp, or the current local time if no timestamp is given.

  	
<?php
    $today = getdate();
    print_r($today);
?>
Output :
[seconds] => 45
[minutes] => 15
[hours] => 17
[mday] => 21
[wday] => 5
[mon] => 08
[year] => 2009
[yday] => 232
[weekday] => Friday
[month] => August
3. checkdate() :
Syntax bool checkdate(int month, int day, int year);
it returns boolean value either true or false.
example:

checkdate(15,35,2006);

Explanation:

Checks the specified date in the argument is valid or not.

  	
<?php
    print checkdate(12,15,2008);
?>
Output :
1

Questions

  1. Write a code for getting the next 3 days dates in format MM/DD/YYYY ?
  2. Write a code for getting todays date in MM-DD-YYYY format ?
After editing Click here:
Output:
Hello World