From: William James Date: 2005-08-30T03:21:22+09:00 Subject: Re: Date problem. ober wrote: > I have read over the man pages and can not seem to find a way to do the > following > > > -----php--------------- > $lastmonth = mktime(0, 0, 0, date("m")-1, date(01), date("Y")); > $name = date('Y-m-d', $lastmonth); > echo "$name\n"; > ----php---------------- > > Where the first day of the previous month is listed. > In this case you would get 2005-07-01 If you don't want to require 'Date': month,year = Time.now.to_a[4..5] month -= 1 month, year = month+12, year-1 if month < 1 puts "%d-%02d-01" % [ year, month ]