/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Add a month to a strftime(‘%x’) date

I have a date(‘d/m/y’) date added to a MySQL database & then gotten & displayed on a page. How do I get the same date from the MySQL database (displayed as dd/mm/YY) & add 1 month.

Any help would be appreciated.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogOct 25.2009 — You could add it as another field to select from your query:
<i>
</i>SELECT <span><code>date_col</code></span>, <span><code>date_col</code></span> + INTERVAL 1 MONTH AS <span><code>next_month</code></span> FROM . . .

Alternatively, if you've converted the query result into a UNIX timestamp integer in your code:
[code=php]
$nextMonth = strtotime('+1 month', $timestampValueFromDB);
[/code]
Copy linkTweet thisAlerts:
@mattwidgeauthorOct 27.2009 — I've found a way that instead of displaying a month from a certain date, it shows the last day of the month instead. This suits my needs fine.
×

Success!

Help @mattwidge spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...