Forum Moderators: coopster
Any help in this would be appreciated before I write a many line routine that has to break the original date into three sections then determine the day of the year (taking into account leap years).
I'm sure (crossing fingers) there is a way to use built in PHP functions to do this in a couple of steps !
Thanks !
- Dan
I pull a date from the data base into $date. (format Ymd i.e. YYYYMMDD). I want to convert it to a Julian date format yz (YYDDD where DDD is the day of the year and YY is the last two digits of the actual year).
You can assign a variable to the absolute current date/time using the date() function....which is how they got that into the database in the first place: $today = date(Ymd);
I would like to be able to take the $date from the database (in format YYYYMMDD) and make $exp equal to the julian date (equivalent of if during the original timestamp, date(yz);
- Dan
- Dan
THANK YOU THANK YOU THANK YOU....and this is excellent learned material to apply to other conversions when and if they come up ! now that I know how to do them !
- Dan (Fengshui)
Since you only get 4 digits for year or last 2 using date()...I went ahead and chose the 2 digit version.
This was just to do some simple math to calculate how far out from an expiration data a subscription is...."less than 60 days", "less than 30 days", or "less than 15 days". Nothing where the year is critical in determining anything other than subscription expired (and I am using the Ymd that is stored in the database for that calculation).
I need to figure out a way to take the date that is stored in the data base in Ymd format (YYYYMMDD) + 10000 to get the expiration date) and compare that (we'll call it $exp) to todays date ($today) and determine if the subscription is within 60, 30, and 15 days respectively of expiration.
Anyways, thanks for the replies so far and will still be hoping someone has a simple answer using the built in functions to accomplish this.
- Dan
I've gotten (fairly) quick and totally accurate responses without condescending "I'm so smart, why are you so dumb" innuendoes to every question I've posed thus far (the Pay Pal Developers Forum is one of the worst for the "Holier than thou" replies LOL) and this forum covers just about everything (PHP, Javascript, HTML, etc. etc.).
Thank You VERY MUCH again and once again I've learned something new that I can use and take "miles" further down the road. If I'm not mistaken and remember correctly, I think PERL also uses those functions (hopefully the same way)...my first server side scripting experience came from puzzling out an existing PERL script, then buying a book, learning enough to become slightly dangerous (to myself) and writing an online "alumni directory" from scratch (about a year and a half ago).
Been pretty much on PHP and mySql the last 3-4 months (first time working with either) and have passed the "dangerous" point now (I think) and maybe to the point where can finally do some good with it.
- Dan (fengshui)
I've learned some good stuff from the PP forum but I've never had to post anything. I think Webmaster World is the bee's knees, and of course the php forum is the best of the best <grin>.
You're certainly welcome, and good luck with the project. PHP is an awesome language. You'll find that there's generally several different ways to go about doing whatever you want to do.
you could probably use mysql to format your date in the query:
DATE_FORMAT function [dev.mysql.com]
mysql date and time types [dev.mysql.com]