weeks in a year


Posted on 16th Feb 2014 07:03 pm by admin

hi,

i found this snippet on php.net
QuoteFor the week number for weeks starting on Sunday:

<?php
function week_of_year($month, $day, $year) {

$day_of_year = date('z', mktime(0, 0, 0, $month, $day, $year));

/* Days in the week before Jan 1. If you want weeks to start on Monday make this (x + 6) % 7 */
$days_before_year = date('w', mktime(0, 0, 0, 1, 1, $year));

$days_left_in_week = 7 - date('w', mktime(0, 0, 0, $month, $day, $year));

/* find the number of weeks by adding the days in the week before the start of the year, days up to $day, and the days left in this week, then divide by 7 */
return ($days_before_year + $day_of_year + $days_left_in_week) / 7;

}
?>


so if i go : week_of_year(1, 3, 2010) (sunday)

the week shows as 1, because the script is set to begin new week on sunday,

however i am confused by his instruction " (x + 6) % 7 " to have the week start on a monday

what part of the script do i apply this equation ???

thanks

No comments posted yet

Your Answer:

Login to answer
142 Like 13 Dislike
Previous forums Next forums
Other forums

selection tool on raster image
Hi!
I have to implement in my app a selection tool which lets users to select region of any shape

Track downloads' status
Hello,

I need to make somehow, some system, to track whether downloads are completed or faile

php libs/ browsercap.in
ok i have a host that refuses to stay current. they control my php settings and libs. is there a way

Save User Inputs while javascript reloading!
hi..
i have written a PHP code in which i reload the page when user selects a value in dropdown..

RSS feed - FeedList for WordPress
Hi,

I'm trying to alter the FeedList plugin for WordPress so that I can click on the title of

Help! refer to a friend script with captcha code
Hi guys, I am posting on here in desperate need for some help with an ongoing search I have been doi

Call db table from any PHP file
Hi,

I want to be able to call a database table that will be setup in another file called init

$_FILES array
Ok,

I just started experimenting with PHP today. My goal right now is to have people be able

Nested (echoed) php running wrong script
Got a problem with a php website I'm creating.

In a nutshell, the first page is entirely html

Form Help
Here is the form:

Line number On/Off | Expand/Contract<? include("../include/sess

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash