How to get date after 3 months in php?
I have a variable called Show I am trying to add three months to this date and have been unsuccessful at it. Here is what I have tried:
and
What am I doing wrong? Neither piece of code worked.
Pops 29.5k36 gold badges133 silver badges151 bronze badges asked Mar 26, 2012 at 15:33
user979331user979331 9,48765 gold badges213 silver badges392 bronze badges 6 Change it to this will give you the expected format:
answered Mar 26, 2012 at 15:41
5 This answer is not exactly to this question. But I will add this since this question still searchable for how to add/deduct period from date.
answered Jun 5, 2018 at 10:11
SadeeSadee 2,66432 silver badges35 bronze badges 0 I assume by "didn't work" you mean that it's giving you a timestamp instead of the formatted date, because you were doing it correctly:
answered Mar 26, 2012 at 15:41
NickNick 6,2282 gold badges28 silver badges46 bronze badges You need to convert the date into a readable value. You may use strftime() or date(). Try this:
This should work. I like using strftime better as it can be used for localization you might want to try it. answered Mar 26, 2012 at 15:44
JohnnyQJohnnyQ 4,5476 gold badges44 silver badges64 bronze badges Tchoupi's answer can be made a tad less verbose by concatenating the argument for strtotime() as follows:
(This relies on magic implementation details, but you can always go have a look at them if you're rightly mistrustful.)
answered Dec 8, 2015 at 16:44
gleechgleech 3054 silver badges11 bronze badges The following should work,Please Try this:
mkl 86.5k15 gold badges124 silver badges249 bronze badges answered Apr 4, 2017 at 7:29
Following should work
answered May 25, 2017 at 10:44
RickyRicky 1351 silver badge8 bronze badges Add nth Days, months and years
answered Aug 8, 2018 at 10:10
The following should work, but you may need to change the format:
answered Mar 26, 2012 at 15:40
Brendon DuganBrendon Dugan 2,1107 gold badges32 silver badges63 bronze badges
answered Sep 1 at 16:14
How to add 1 month in date in php?php $dt = strtotime("2012-12-21"); echo date("Y-m-d", strtotime("+1 month", $dt)).
Which function can be used to change the date from current month to three months previous?You can use the EDATE function to quickly add or subtract months from a date. The EDATE function requires two arguments: the start date and the number of months that you want to add or subtract. To subtract months, enter a negative number as the second argument. For example, =EDATE("9/15/19",-5) returns 4/15/19.
What is the use of date() function in php?The date() function formats a local date and time, and returns the formatted date string.
How can I get plus date in php?The date_add() function adds some days, months, years, hours, minutes, and seconds to a date.
|