Date Function
To display in numeric format:
1. d, a lower case d, stands for date of the month( 1 to 31).
2. m, a lower case m, stands for the month( 1 to 12).
3. y, a lower case y, stands for the year(in two digits).
To display in text format:
1. D, a capital D, stands for day of the month in tex( Saturday, Sunday, etc. ).
2. M,a capital M, stands for the month in text( 1 to 12).
3. Y, Capital Y, stands for date of the year(in four digits).
1. d, a lower case d, stands for date of the month( 1 to 31).
2. m, a lower case m, stands for the month( 1 to 12).
3. y, a lower case y, stands for the year(in two digits).
To display in text format:
1. D, a capital D, stands for day of the month in tex( Saturday, Sunday, etc. ).
2. M,a capital M, stands for the month in text( 1 to 12).
3. Y, Capital Y, stands for date of the year(in four digits).
To display in numeric format:
Example: 1
<?phpecho date("d/m/y");
?>
Output
30/04/12You can change the format like period.
Example: 2
<?phpecho date("d.m.y");
?>
Output
30.04.12You can also use minus sign.
Example: 3
<?phpecho date("d-m-y");
?>}
Output
30-04-12
To display in text format:
Example: 1
<?phpecho date("D/M/Y");
?>
Output
Mon/Apr/2012You can change the format like period.
Example: 2
<?phpecho date("D.M.Y");
?>
Output
Mon.Apr.2012You can also use minus sign.
Example: 3
<?phpecho date("D-M-Y");
?>}
Output
Mon-Apr-2012 To display full date:
Example: 4
<?phpecho date("d D M Y");
?>}
Output
30 Mon Apr 2012
The following example will output "Have a nice weekend!" if the current day is Sunday, otherwise it will output "Have a nice day!":
Example: 5
<?php
$d=date("D");
if ($d=="Sun")
echo "Have a nice weekend!";
else
echo "Have a nice day!";
?>
Output
Have a nice day!
No comments:
Post a Comment