[SOLVED] - Date Structuring

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Hang on.. $frequencycurrent is what? A previous result? If so, keep the result from strtotime() in a separate variable. Pass that to strtotime() on the second iteration. Or rather always pass it, but for the initial run, set it to time().
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

since the date is all screwed up in ddmmyy format, which neither sorts naturally nor is welcomed by any functions, you'll have to plug in a bit more code than that I'm afraid :-(

For the sake of space I'm going to make a reference to your long-ass-variable (which is fine, don't get me wrong!)

Code: Select all

$fc=&$frequencycurrent;

$fc = date('dmy',strtotime('+2 weeks',mktime(0,0,0,substr($fc,2,2),substr($fc,0,2),substr($fc,4,2))));
substr() returns substrings of your date format for month, day and year (in that order, which mktime() wants)

mktime() makes a unix timestamp out of those variables

strtotime() adds 2 weeks to it

finally date() turns it back into your strange date format.

It's kludgy but it works.

Cheers,
Kieran
User avatar
iknownothing
Forum Contributor
Posts: 337
Joined: Sun Dec 17, 2006 11:53 pm
Location: Sunshine Coast, Australia

Post by iknownothing »

that piece of code should be called a broom, did a great job of sweeping up my mess, cheers.
Post Reply