Categories: PHP

Get all days and dates for the selected month of a year using php

Try this code for following purpose

  1. Get all days and dates for the selected month of a year using php
  2. How to get full day name from date in php
  3. Get day name from date in PHP

Just Follow below step and you will Get day name from date in PHP or print all dates, days of current month

### Step1: 
 
<?php
date_default_timezone_set('Asia/Kolkata');
$month = date('m');
$year = date('Y');
$cur_date = date('Y-m-d');

$d = $day_count =cal_days_in_month(CAL_GREGORIAN,$month,$year);


$cdate=date('d');

?>

### Step2:

    <?php
        $day = 1;
        while($d){             
            ?>

                    <p>
                        <?php 

                        if($day=="$cdate") {
                            echo "<b>".$dated = ($day++.' '.(date("M Y")))."</b>";
                        } 
                        else 
                        {
                            echo $dated = ($day++.' '.(date("M Y"))); 
                        }
                        echo '('.$day_name = date('D', strtotime($dated)).')';

                        ?>
                            
                    </p>
                        
    <?php  $d--; } ?> 

Basant

Recent Posts

How to Add Auto Increment to a Column in PostgreSQL ?

Learn how to efficiently set up auto-increment columns in PostgreSQL with this step-by-step guide. From…

4 hours ago

How to get the value of selected radio button using jQuery

Just use below code and modified according to your need. Note: this is very useful…

3 months ago

AWS

Steps: AWS puttyubuntu sudo su apt update apt install apache2 service apache2 start service apache2…

8 months ago