Re: Help converting ASP->PHP
| From: | Curt A. Gilman | Date: | Fri, 19 Oct 2001 22:11:35 +0000 |
| Subject: | Re: Help converting ASP->PHP | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-71637@lists.php.net to get a copy of this message | ||
You should be able to do everything with PHP's date functions:
http://www.php.net/manual/en/ref.datetime.php
Pay particular attention to the mktime, date, and getdate functions. The
script below might be helpful to you.
<?
function begin_month($timestamp)
{
$a = getdate($timestamp);
return mktime(0, 0, 0, $a["mon"], 1, $a["year"]);
}
function end_month($timestamp)
{
$a = getdate($timestamp);
return mktime(0, 0, 0, $a["mon"] + 1, 0, $a["year"]);
}
function weekday($timestamp)
{
$a = getdate($timestamp);
return $a["wday"];
}
$date = mktime(0, 0, 0, 12, 15, 2001);
echo date("M/d/Y", begin_month($date)), "\n";
echo date("M/d/Y", end_month($date)), "\n";
echo weekday($date), "\n";
?>
__________
Curt A. Gilman
Richmond, Virginia, USA
curt@gilm.net
"Mrbaseball34" <mrbaseball34@hotmail.com> wrote in message
news:MPG.163a50522b60daef989684@news.php.net...
> PHP Newbie, so please don't flame me <bg>!
>
> I am converting an organizer example from an ASP book to PHP
> and need some help.
>
> Need some help with the following code :
>
> /*
> intMonth and intYear are variables passed into a function
> datCurrent, intCurrentMonthDays and intWorkDays are local
> variables
> */
>
> datCurrent = CDate(intMonth & "/1/" & intYear)
> intCurrentMonthDays = _
> Day(DateAdd("d", -1, DateAdd("m", 1, datCurrent)))
> intWeekday = Weekday(datCurrent)
>
> I can't find any PHP functions to handle this type of day/date
> manipulation...