time to string php code example
Example 1: php convert us date to european
$originalDate = "2010-03-21";
$newDate = date("d-m-Y", strtotime($originalDate));
Example 2: php timestamp to date
<?php
echo date('m/d/Y H:i:s', 1541843467);
?>
Example 3: php time format
$today = date("F j, Y, g:i a");
$today = date("m.d.y");
$today = date("j, n, Y");
$today = date("Ymd");
$today = date('h-i-s, j-m-y, it is w Day');
$today = date('\i\t \i\s \t\h\e jS \d\a\y.');
$today = date("D M j G:i:s T Y");
$today = date('H:m:s \m \i\s\ \m\o\n\t\h');
$today = date("H:i:s");
$today = date("Y-m-d H:i:s");
Example 4: Datetime to string php
<?php
$date = new DateTime('2000-01-01');
echo $date->format('Y-m-d H:i:s');
?>
Example 5: time to string in php
<?php
$date = '27/06/2020, 04:42:43 PM';
$date = str_replace('/', '-', $date);
echo date('F j, Y, g:i a',strtotime($date));
?>
Example 6: date to string php
$date_string_prepared = date_create("2020-08-07");
$date_string = $date_string_prepared->format("d M Y");