php date to timestamp code example
Example 1: php get current date and time
$today = date("F j, Y, g:i a");
$today = date("D M j G:i:s T Y");
$today = date("Y-m-d H:i:s");
Example 2: php timestamp to date
<?php
echo date('m/d/Y H:i:s', 1541843467);
?>
Example 3: php datetime object get unix timestamp
$date = new DateTime();
echo $date->getTimestamp();
Example 4: timestamp php
<?php
$date = new DateTime();
echo $date->getTimestamp();
?>
Example 5: 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 6: 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));
?>