Answers for "change format of date time object in php"

PHP
8

php change date format

To convert the date-time format PHP provides strtotime() and date() function. We change the date format from one format to another.

Change YYYY-MM-DD to DD-MM-YYYY
<? php.
$currDate = "2020-04-18";
$changeDate = date("d-m-Y", strtotime($currDate));
echo "Changed date format is: ". $changeDate. " (MM-DD-YYYY)";
?>
Posted by: Guest on April-18-2020
1

php change date format

<?php
  	#https://moneyconvert.net/
    $source = '2012-07-31';
    $date = new DateTime($source);
    echo $date->format('d.m.Y'); // 31.07.2012
    echo $date->format('d-m-Y'); // 31-07-2012
?>
Posted by: Guest on October-28-2021

Code answers related to "change format of date time object in php"

Browse Popular Code Answers by Language