I need help writing a function for the following situation.
User inputs dates (as a single string) in the format of MM/DD/YYYY.
I need to convert this to YYYYXXX where XXX is the day of the year from 001 to 365.
As a seperate function, I need to convert YYYYXXX back to PHP native time format for conversion to MySQL format.
Any Ideas?!
Sounds like you need to use the strtotime function to get your original date into Unix format. From there you can use the date function to get it back out in any format you choose.
http://www.php.net/manual/en/function.strtotime.php
Sorry,
Maybe I was not clear, I need the date in the format of YEARXXX
where Year is the four digit year, and XXX is 001 through 365, not 1 through 365.
date(Yz) will return 19751 for Jan 1, 1975
I need 1975001 returned....
Any suggestions? Please!
$formatedTime = date("Yz");
Frag
I fixed it with IF statements,
if (date(z, $date)<10) { $newdate = date(Y00z, $date); }
etc etc
anyone have a Nicer methopd?
rag Date(Yz) will not work....it reutnrs only 1-365 not 001 through 365....
AHHHHHHHHHHHHHHHHH!!!!!!!!!!!!!!!!!
For some reason I can get if statements (see above) to work alone within a page, but not within a function?!
Originally posted by Tracer AHHHHHHHHHHHHHHHHH!!!!!!!!!!!!!!!!! For some reason I can get if statements (see above) to work alone within a page, but not within a function?!
I believe your problem is in the declaration of your variables. Variables outside the function are not within the scope of that function unless you declare them that way.