Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2014-03-31 08:40:18

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,137
GitHub

[solved] Display current and next month with PHP

I’d like to display the current and next month on a page, like this:

March 2014 and April 2014

At the moment, I’m using this:

<txp:php>echo date("F Y");</txp:php> and <txp:php>echo date("F Y", strtotime("+1 month"));</txp:php>

Today, the last day of the month, it’s displaying this:

March 2014 and May 2014

My server is in America/Los Angeles timezone, and it’s still March. My Textpattern is also set to America/Los Angeles. I am in Europe/Londonand it’s still March here. Is there a better way to achieving what I want, or is this just a flub that happens on the last day of a given month?

Thanks!

Last edited by gaekwad (2014-03-31 10:09:35)

Offline

#2 2014-03-31 09:03:01

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: [solved] Display current and next month with PHP

Hi, Pete,

try strtotime("first day of next month").

Offline

#3 2014-03-31 10:09:14

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,137
GitHub

Re: [solved] Display current and next month with PHP

That worked – thank you very much, Oleg.

Offline

Board footer

Powered by FluxBB