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 Center submit button of wpForm

You must navigate to Settings ยป General first. Add wpf-center to the Form CSS Class…

8 months ago

How to add Marquee on any website wordpress,PHP,HTML,eBlogger ?

if you want to add marquee on any website (wordpress,PHP,HTML,Blogger). you just need to follow…

8 months ago

How to Autoplay and Loop YouTube Videos in WordPress

First Method: Use below code to play youtube video in loop and most important is…

1 year ago

How to Disable WP JSON Rest API in WordPress without plugin ?

just add below code in wordpress theme function.php file at the bottom -------------------------------------------------- Add the…

1 year ago