Reputation: 3794
I'm trying to print date.
Example,
$firstMonth = "4";
$firstYear = "2013";
for ( $i=0; $i<6; $i++)
{
$new_date= date( "Ym", mktime(0, 0, 0, $firstMonth-$i, 1, $firstYear) );
print $new_date."\n";
}
Result,
201304
201303
201302
201301
201212
201211
My requiment is, to print like
20134
20133
20132
20131
201212
201211
How can i delete the "ZERO" in this situation?
Any good idea?
Upvotes: 0
Views: 95
Reputation: 14681
As explained in PHP Date documentation:
m: Numeric representation of a month, with leading zeros
n: Numeric representation of a month, without leading zeros
So use this format instead:
$new_date= date( "Yn", mktime(0, 0, 0, $firstMonth-$i, 1, $firstYear) );
Upvotes: 5