Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get 1st day of next month [duplicate]

Possible Duplicate:
how to find first day of the next month and remain days to this date with php

I have this to get 1st day of current month

$_SERVER['dataInicio'] = date('Y') . "-" . date('m') . "-" . "1";

I need something similar to get 1st day of NEXT month

like image 980
CMartins Avatar asked Nov 16 '12 18:11

CMartins


People also ask

How do you get the first day of the next month in Excel?

For getting the first day of next month based on given date in Excel, the following formula can help you. Select a blank cell, enter formula =DATE(YEAR(A2),MONTH(A2)+1,1) into the Formula Bar and then press the Enter key. Then use the Fill Handle to get the rest dates.

How do I get the same date next month in Excel?

To get the same date next month from a given date, you can use the EDATE function. EDATE can get the "same date" in the future or past, based on the number of months supplied. When 1 is given for months, EDATE gets the same date next month.

How do you get the first day of the month?

The EOMONTH function returns the last day of the month for a given date. So, in this formula EOMONTH first returns a date corresponding to the last day of the month, and then DAY returns the date... Working from the inside out, the EOMONTH function gets the last day of month of any date.

How do I get the next day from a date in Excel?

Enter your due dates in column A. Enter the number of days to add or subtract in column B. You can enter a negative number to subtract days from your start date, and a positive number to add to your date. In cell C2, enter =A2+B2, and copy down as needed.


1 Answers

$date = new DateTime('now');

$date->modify('first day of next month');
echo $date->format('D') . '\n';

$date->modify('first day of this month');
echo $date->format('D') . '\n';
like image 63
rscata Avatar answered Sep 19 '22 04:09

rscata