Hi, If you want "last month" from the *CURRENT* date + time, then look at something like strtotime('last month'), which may help, generating a time stamp of the same day, time, etc in the previous month.
To format a different time stamp into what you want, consider the date() function in the manual... for starters, it's quicker for the code you have below: NOTE: untested code :) <? $timestamp = time(); $formated_date = date('m/d/Y', $timestamp); echo $formated_date; // echos what you already had ?> however, since we want to have one less month: <? $timestamp = time(); $month = date('m', $timestamp); $day = date('d', $timestamp); $year = date('Y', $timestamp); // subtract 1 from $month, unless it's // value is 1, in which case it should be // 12, and the year dropped by 1 as well if($month == 1) { $month = 12; $year = $year - 1; } else { $month = $month - 1; } $formatted_date = "{$month}/{$day}/{$year}"; echo $formatted_date; ?> I have no idea why you want to output "April" in addition to "4", but you can take your $formatted_date, feed it into strtotime(), which gives you the new timestamp. From there, you can get a word month out of the date() function, which gives you the text "April": <? //.. continued from above code $new_timestamp = strtotime($formatted_date); $month_t = date('F', $new_timestamp); echo $month_t; ?> There are prolly better ways to do this, but you can see, if you think about it, and read the manual (just two pages!!!!!!!!!), you'll get what you want. Justin French on 21/05/02 1:01 AM, Randy Johnson ([EMAIL PROTECTED]) wrote: > Is their a way to retrieve the previous month using/altering the code > below: > > // get the current timestamp into an array > $timestamp = time(); > $date_time_array = getdate($timestamp); > $month = $date_time_array["mon"]; > $day = $date_time_array["mday"]; > $year = $date_time_array["year"]; > $tmonth= $date_time_array["month"]; > > outputs > > 5202002 May > > i need it to output > 4/20/2002 April > > > Thanks > > Randy > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php