How can get current year in php
Posted by Raj
How can get current year in php.
In this article,I will show how to get Current Year in PHP.
The PHP Date() Function:
The PHP date() function formats a date and time.
Syntax
date(format,timestamp)
d - Represents the day of the month (01 to 31)
m - Represents a month (01 to 12)
Y - Represents a year (e.g.2012)
Example:
<?php
echo $date=date('Y');//Get Current Year in PHP
?>
Output:
2012.
In this article,I will show how to get Current Year in PHP.
The PHP Date() Function:
The PHP date() function formats a date and time.
Syntax
date(format,timestamp)
d - Represents the day of the month (01 to 31)
m - Represents a month (01 to 12)
Y - Represents a year (e.g.2012)
Example:
<?php
echo $date=date('Y');//Get Current Year in PHP
?>
Output:
2012.
This entry was posted on October 4, 2009 at 12:14 pm, and is filed under
current year in php,
date format in php,
date function,
PHP,
php date,
PHP interview questions and answers
.You can leave a response, or trackback from your own site.