PHP date last year

PHP date last year


Posted in : PHP Posted on : January 28, 2011 at 6:44 PM Comments : [ 0 ]

In this tutorial you will learn how to find PHP date of last year in a PHP web application .

PHP date last year

In this tutorial you will learn how to find PHP date of last year in a PHP web application . The $current_date variable that store current date and strtotime() that return  date to Unix timestamp.  When  pass parameter ( "-1 year",$strtotime ) in    strtotime() function it return one year before timestamp that also date of last year . The code of "php-date-last-year.php"  given below :

<?php
$current_date=date("Y-m-d");
echo "Current Date : ".$current_date;
echo "<br>";
$strtotime=strtotime($current_date);
$last_year=strtotime("-1 year",$strtotime);
echo "Date last year : ";
echo date("Y-m-d",$last_year);
?>

Output :

When run "php-date-last-year.php" display output as :

Download Source Code

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics