Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with dates 1

Status
Not open for further replies.

JCrou82

Programmer
Aug 23, 2002
265
US
I have a site that currently shows you their mailer dependent upon the date. They show this month, the previous month and the month before that, so that on December it also shows November and October. But now that is January, it shows December and December. Here is the code and I've been working on it for a few hours now and even attempted at looking at Calendar scripts, but they don't need to list the previous TWO months. Can someone help. Here is the code I'm trying to debug. It's work until now...:

$todayDate = date("F");
$backm_one = mktime (0,0,0,date("m"),0,0);
$backm_two = mktime (0,0,0,date("m")-1,0,0);
$oneMonth = date("F", $backm_one);
$twoMonth = date("F", $backm_two);

print $today . " " . $oneMonth . " " . $twoMonth;

This will print out March through December: CurrentMonth PreviousMonth TwoMonthsAgo (ie September August July) etc.

but on February and January, it prints out: January/February December December

Can anyone help or point me to the right direction?

Thank You
 
You're trying to go to year -1, add in the year to your mktime function.

$backm_one = mktime (0,0,0,date("m"),0, date("Y"));
$backm_two = mktime (0,0,0,date("m")-1,0,date("Y"));

-Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top