php get current date code example
Example 1: php get current year
$currentYear=date("Y");
Example 2: 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 3: 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 4: date php
$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 \e\s\t\ \l\e\ \m\o\i\s');
$today = date("H:i:s");
$today = date("Y-m-d H:i:s");
Example 5: php get day from date
$timestamp = strtotime('2009-10-22');
$day = date('D', $timestamp);
var_dump($day);
Example 6: 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');