PHP Date and Time
EXPLAIN
The PHP date() function is used to format a date and/or a time.
SYNTAX
date(format,timestamp)
**Note:
format - Required. Specifies the format of the timestamp
timestamp - Optional. Specifies a timestamp. Default is the current date and time
Here are some characters that are commonly used for dates:
- d - Represents the day of the month (01 to 31)
- m - Represents a month (01 to 12)
- Y - Represents a year (in four digits)
- l (lowercase 'L') - Represents the day of the week
SAMPLE CODE & OUTPUT
<?php
echo "Today is " . date("Y/m/d") . "<br>";
echo "Today is " . date("Y.m.d") . "<br>";
echo "Today is " . date("Y-m-d") . "<br>";
echo "Today is " . date("l");
?>
Output:
Today is 2016/05/10
Today is 2016.05.10
Today is 2016-05-10
Today is Tuesday
Reference:
http://www.w3schools.com/php/php_date.asp
http://php.net/manual/en/function.date.php
Reference:
http://www.w3schools.com/php/php_date.asp
http://php.net/manual/en/function.date.php
No comments:
Post a Comment