Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

Date Format YYDDD (julian?)

Posted on 2004-08-04
Medium Priority
538 Views
Hello I am looking to get a day format of YYDDD i think it is a julian day.

when i do

echo date("yz");

it gives me 04216, but with leap year the actual date is 04217.

Does anyone know how I can get the actual julian day?
0
Question by:jmsloan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 4
• 3
• 2

LVL 33

Assisted Solution

snoyes_jw earned 120 total points
ID: 11717859
z gives the day of the year starting with 0.  If you want it starting with 1, just add one.
echo date("yz") + 1;
0

LVL 3

Author Comment

ID: 11717958
what is going to give me the format i need  YYDDD

what if it is the 2 day of the year I need it to say

04002
0

LVL 33

Expert Comment

ID: 11718008
as I said, date("yz") + 1;
0

LVL 27

Accepted Solution

Diablo84 earned 80 total points
ID: 11718022
try

\$var = date("y");
\$var2 = date("z");
\$out = \$var.\$var2;

echo \$out;
0

LVL 27

Expert Comment

ID: 11718026
sorry, should be

\$var = date("y");
\$var2 = date("z");
\$out = \$var.\$var2;

echo \$out;
0

LVL 33

Expert Comment

ID: 11718029
ah, but then we lose leading zeros.  I'll find it here in a second...
0

LVL 33

Expert Comment

ID: 11718038
There, what Diablo84 said, but you'll still need to increment it, otherwise the first day of the year will come out as 04000.
0

LVL 27

Expert Comment

ID: 11718059
true, so...

\$var = date("y");
\$var2 = date("z") +1;
\$out = \$var.\$var2;

echo \$out;
0

LVL 3

Author Comment

ID: 11718668
Sorry that should have been the other way around
0

Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month7 days, 1 hour left to enroll