/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] PHP date function ‘z’

Hello using the PHP date function “z” says it goes from 0-365 found here [url]http://www.php.net/manual/en/function.date.php[/url]

But 0 shows is a non working field why do they list it that way? I can only get something to actually show
for today dec 11 2008 [url]http://www.vpcalendar.net/Julian_Date.html[/url] if I include something on number 345.

When according to the php manual should only show at 344 instead since first one is supposed to start at 0 not 1.

Can someone please explain this to me? Am trying to explain it to someone else on how php manual yearly date z works and can’t, since it isn’t making any sense.

Please let me know why the php manual says it should start at 0 when items are only showing starting at 1 instead. Thank you very much for your help.

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@NogDogDec 11.2008 — I think you may be neglecting the fact that this is a leap year, and as such there are 366 days this year, so 345 is correct for Dec. 11, 2008.
Copy linkTweet thisAlerts:
@vortexerauthorDec 11.2008 — Thanks a lot if you look at the http://www.vpcalendar.net/Julian_Date.html their first number starts at 001. So for leap year means something should show on 344 not 345 since z is supposed to start at 0 for their number 1. Isn't that correct?
Copy linkTweet thisAlerts:
@NogDogDec 12.2008 — OK, so if we start at 0, that means this year (a leap year) Dec. 31 will be day number 365 (The 366th day of the year minus 1). If we subtract 20 from 365 we get 345, and if we subtract 20 from Dec. 31 we get Dec. 11. Therefore, the "z" day for Dec. 11, 2008 is 345, which is what I get with [b]date('z');[/b].
[code=php]
<?php
$dates = array('2008-01-01', '2008-12-11', '2008-12-31');
foreach ($dates as $date)
{
echo "<p>$date: ".date('z', strtotime($date))."</p>n";
}[/code]

Output:
<i>
</i>2008-01-01: 0

2008-12-11: 345

2008-12-31: 365
Copy linkTweet thisAlerts:
@vortexerauthorDec 12.2008 — Thank you very much are you saying this online calandar then is incorrect since this is leap year?

http://www.vpcalendar.net/Julian_Date.html

It only show 1-365 days. Other online calandars I am finding show the same thing. Please let me know thanks a lot.
Copy linkTweet thisAlerts:
@NogDogDec 12.2008 — Yes, they are not accounting for leap years. In a leap year, every day after Feb 28 will have a "z" value which is 1 higher than in non leap years.
Copy linkTweet thisAlerts:
@vortexerauthorDec 12.2008 — Thanks a whole lot makes real sense now appreciated. Leap year sort of clouded the thinking.
×

Success!

Help @vortexer spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...