Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find a start date & end date of any given year & month

Tags:

php

I have problem in php find start date & end date of month & year , when i know the year and month ?

ex:

input - > year = 2011 , month = 08
output -> start date = 01 , end date = 31
like image 994
Jayanath Avatar asked Aug 25 '11 03:08

Jayanath


People also ask

How do I find my start date and end date?

Subtract Dates in Excel To find the number of dates between the start date and end date, use this formula in cell C2: =B2-A2.

How do you find the start date from the week?

Note: This formula =A2-WEEKDAY(A2,2)+1 will return Monday as the beginning of week based on the given date. Select a blank cell you will return the beginning of week, and enter the formula =A2-MOD(A2-2,7) (A2 is the cell with given date) into it, and then drag the Fill Handle to the range as you need.


2 Answers

echo date('m-01-Y 00:00:00',strtotime('this month')) . '<br/>';
echo date('m-t-Y 12:59:59',strtotime('this month')) . '<br/>';
like image 113
Roshan Wijesena Avatar answered Sep 20 '22 08:09

Roshan Wijesena


Start date will always be 1 and you can find the end date with the following function.

cal_days_in_month(CAL_GREGORIAN, $month, $year);

reference:

cal_days_in_month ( int $calendar , int $month , int $year ) : int

like image 35
Joe Landsman Avatar answered Sep 19 '22 08:09

Joe Landsman