get current date php code example
Example 1: get current year php
<?php echo date("Y"); ?>
Example 2: php get current year
$currentYear=date("Y");
Example 3: 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 4: php today date
<?php
echo "Today is " . date("Y/m/d") . "<br>";
echo "Today is " . date("Y.m.d") . "<br>";
echo "Today is " . date("Y-m-d") . "<br>";
echo "Today is " . date("l");
Example 5: php date timestamp now
$date = date('Y-m-d H:i:s');
$date = date('Y/m/d H:i:s');
$date = '2012-03-06 17:33:07';
$date = '2012/03/06 17:33:07';
date_default_timezone_set('Africa/Nairobi');
$date = date('Y-m-d H:i:s');
$date = date('Y/m/d H:i:s');
Example 6: php format date
<?php
$old_date_format = "20/03/1999";
$new_data_format = date("Y-m-d H:i:s", strtotime($old_date_format));