Syn3sthete
0
Q:

Datetime to string php

PHP date_format() Function

Example
Return a new DateTime object, and then format the date:

<?php

 $date=date_create("2020-03-09");
echo date_format($date,"Y/m/d H:i:s");
?>
 
9
$s = '06/10/2011 19:00:02';
$date = strtotime($s);
echo date('d/M/Y H:i:s', $date);
0

<?php
$date = new DateTime('2000-01-01');
echo $date->format('Y-m-d H:i:s');
?>

1
$date_string_prepared = date_create("2020-08-07");
$date_string = $date_string_prepared->format("d M Y");
// result 07 Jul 2020
2
$today = date("F j, Y, g:i a");                 // March 10, 2001, 5:16 pm
3

New to Communities?

Join the community