get current day php code example
Example 1: php get day from date
$timestamp = strtotime('2009-10-22');
$day = date('D', $timestamp);
var_dump($day);
Example 2: get day from date php
echo date("l") . "<br>";
Example 3: php get day of week
date('w');
if(date('w') == 1){
echo "its monday baby";
}
Example 4: get day of month php
cal_days_in_month(CAL_GREGORIAN, $month, $year)
echo (cal_days_in_month(CAL_GREGORIAN, 2, 2020));
function days_in_month($month, $year) {
return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year % 400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31);
}
echo (date('t', strtotime('2020-02-1')));
Example 5: php date
<?php
date_default_timezone_set('UTC');
echo date("l");
echo date('l jS \of F Y h:i:s A');
echo "July 1, 2000 is on a " . date("l", mktime(0, 0, 0, 7, 1, 2000));
echo date(DATE_RFC2822);
echo date(DATE_ATOM, mktime(0, 0, 0, 7, 1, 2000));
?>
Example 6: php get day number
$today = date("d");
print_r($today);