Answers for "how to change dates to string in php"

PHP
1

Convert DateTime to String in PHP

phpCopy$theDate    = new DateTime('2020-03-08');
echo $stringDate = $theDate->format('Y-m-d H:i:s');

//output: 2020-03-08 00:00:00
Posted by: Guest on April-23-2021
2

date to string php

$date_string_prepared = date_create("2020-08-07");
$date_string = $date_string_prepared->format("d M Y");
// result 07 Jul 2020
Posted by: Guest on August-29-2020
0

Convert DateTime to String in PHP

phpCopy$date = date_create_from_format('d M, Y', '08 Mar, 2020');
echo $newFormat = date_format($date,"Y/m/d H:i:s");

//output: 2020/03/08 00:00:00
Posted by: Guest on April-23-2021

Code answers related to "how to change dates to string in php"

Browse Popular Code Answers by Language