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:
[ 0 ] Comments