On Sunday, September 7, 2003, at 02:50 PM, Seth Willits wrote:

A few things I'm trying to do:

1) Turn "MM/DD/YY" into an array like that returned from getdate(). I don't want to explode it or split it, I want to get an array just as if I used getdate() when the current day was MM/DD/YY.

It just dawned on me that the timestamp parameter for getdate() is exactly what does this. So forget this one :)



2) Have a date string representing the first of the month and manipulate it to be the last day of the previous month.

This, I'm still wondering about. This is the code I have:


$month = $date['mon'];
$year = $date['year'];

if ($month == 1) {
$lastofprevmonth = date('t', strtotime('12' . '/01/' . ($year-1) ));
$lastofprevmonth = date('m/d/y', strtotime('12' . '/' . $lastofprevmonth . '/' . ($year-1)));
} else {
$lastofprevmonth = date('t', strtotime(($month-1) . '/01/' . $year));
$lastofprevmonth = date('m/d/y', strtotime(($month-1) . '/' . $lastofprevmonth . '/' . $year));
}



This is a far cry from the simple trick in other languages where you just subtract one from the first of the current month and your date then reflects the last day of the previous month. Can that be done in PHP?



Seth Willits
------------------------------------------------------------------------ ---
President and Head Developer of Freak Software - http://www.freaksw.com
Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com
Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames


"When purchasing that gift for your Special Someone guys remember, girls
like cute things. If it makes you want to puke, your chick will totally
love it."
-- Someone else out There
------------------------------------------------------------------------ ---


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to