mheavers
mheavers

Reputation: 30168

Create new php var which increments from previous var without changing the inital var in PHP

I need to take a variable of the current month (in this case output as the number "1") - and output it is the numbers "02" and "03". I'm trying to do this:

<?php $current_month = "{current_time format="%m"}"; 
$next_month = "0".$current_month++; 
$third_month = "0".$next_month++; 
?>

but this is changing the original variable, which I don't want to do. How do I accomplish this?

Thanks for the help.

Upvotes: 0

Views: 205

Answers (1)

ircmaxell
ircmaxell

Reputation: 165261

Just use + 1:

<?php 
$current_month = "{current_time format="%m"}"; 
$next_month = "0". ($current_month + 1); 
$third_month = "0". ($next_month + 2); ?>

Upvotes: 3

Related Questions