How to create date in PHP

2 Answers

0 votes
$date = date_create('04/12/2022'); // MM/DD/YYYY

echo date_format($date, 'd-m-Y');
 
 
 
  
/*
run:
  
12-04-2022
  
*/

 



answered Mar 24, 2022 by avibootz
0 votes
$date = new DateTime('04/12/2022'); // MM/DD/YYYY

echo $date->format('d-m-Y'); 
 
 
 
  
/*
run:
  
12-04-2022
  
*/

 



answered Mar 24, 2022 by avibootz
...