 |
| ::: T4VN Statistics ::: |
PHP Scripts : 35
|
PHP Example : 67
|
PHP Tutorials : 21
|
PHP News : 91
|
Total Coupon : 36
|
Other Tutorials :
|
Member : 167
|
Visitor Online : 2
|
Today Visit: 341
|
Total Visitor : 84065
|
Most Online : 25
|
|
|
 |
Getting the day of the year
Author : sploit
use this function (usage example given in code) to get the day of the year on a specified date. date is specified by giving the day, month and year.
| PHP Example : |
|
<?
/*
Aug 15th, 2003
sploit
*/
/* specify date. d = day, m = month, y = year */
$d = 2;
$m = 2;
$y = 2000;
/* display date and day of the year (on that date) */
if(day_of_year($m, $d, $y))
{
echo "date: ", date("d-M-Y", mktime(0,0,0, $m, $d, $y));
echo "<BR>day of the year: ", day_of_year($m, $d, $y);
}
else
{
echo 'invalid date!';
}
/*
FUNCTION: day_of_year($month_number, $day_number, $four_digit_year)
if date specified is correct, returns the day of the year
else returns false
*/
function day_of_year($m, $d, $y)
{
if(checkdate($m, $d, $y)!=true)
{
return false;
}
for($i=1 ; $i < $m; $i++)
{
$timestamp = mktime (0,0,0,$i,1,$y);
$num_days_in_month = date("t", $timestamp);
$day_of_year = $day_of_year + $num_days_in_month;
}
$day_of_year = $day_of_year + $d;
return($day_of_year);
}
?>
|
|
|
|

|
 |
| ::: Resources ::: |
|
|
| ::: New Templates ::: |
|
| ::: Other Tutorials ::: |
|
|