PHP Date Change Format

PHP Date Change Format


Posted in : PHP Posted on : January 22, 2011 at 6:21 PM Comments : [ 0 ]

In this tutorial you will learn how to PHP date change format in a PHP web application.

PHP Date Change Format

In this tutorial you will learn how to PHP date change format in a PHP web application. In this tutorial    $currentDate variable store current date and again call changeDateFormat() function that change date format . The code of "php-date-change-format.php" given below :

<?php
function changeDateFormat($date)
{
$date_tmp = explode("/",$date);
$change_date = mktime(0,0,0,$date_tmp[1],$date_tmp[0],$date_tmp[2]);
return date('Y-m-d',$change_date);
}

$currentDate=date("d/m/Y");
echo "Current Date :: ".$currentDate."<br>";
echo "Change Date Format "."<br>";
echo "".$currentDate." ==> ".changeDateFormat($currentDate)."<br>";
?>

Output :

When run "php-date-change-format.php" display output as:

Download Source Code

Go to Topic «PreviousHomeNext»

Your Comment:


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

 
Tutorial Topics