current date php 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 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 3: php get day from date
$timestamp = strtotime('2009-10-22');
$day = date('D', $timestamp);
var_dump($day);
Example 4: 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 5: php current date get
date_default_timezone_set('Asia/Kolkata');
echo date("Y-m-d H:i:s");
Example 6: php current date
# Current date
date_default_timezone_set('Asia/Kolkata');
echo date("Y-m-d H:i:s");
# Current Time
date_default_timezone_set("America/New_York");
echo "The time is " . date("h:i:sa");