Datetime to string php
snippet in php

php datetime format

user5602

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");
?>
 

string to datetime php

user8229

$s = '06/10/2011 19:00:02';
$date = strtotime($s);
echo date('d/M/Y H:i:s', $date);

Datetime to string php

user737


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

date time format php

user3040

$today = date("F j, Y, g:i a");                 // March 10, 2001, 5:16 pm

change datetime format from Y-m-d h:i:s to d-m-Y in php

user3131

$old_date = date('l, F d y h:i:s');              // returns Saturday, January 30 10 02:06:34
$old_date_timestamp = strtotime($old_date);
$new_date = date('Y-m-d H:i:s', $old_date_timestamp);   

php strftime datetime

user1850

setlocale(LC_TIME, 'it_IT.UTF-8');
$date = new DateTime($run['at']);
strftime("%d %B", $date->getTimestamp())