Jump to content
phppup

Up all night with DAYS

Recommended Posts

 

It all looked so simple on paper...

But I'll skip the drama and get right to it:

 

I'm posting $start and want to post $finish as a date that's 3 days afterwards

Apparently, this is wrong somewhere:

$finish = start('d-m-Y', strtotime($start. ' + 3 days'));

echo $finish;

 

On a similar note, I used some script to successfully change mm-dd-yyyy to Y-m-d.

echo $newdate; works fine.

But POST[$newdate] is not connecting.

Any easy answer?

 

And while on the subject, after all this DATE work, I opened Firefox using a form with an HTML input type=date. It displayed mm/dd/yyyy to the user, but intuitively echoed yyyy-mm-dd. Is this a benefit of Firefox or HTML? Is it trusted? Reliable? Will the feature work as default in other browsers?

Share this post


Link to post
Share on other sites

I'm posting $start and want to post $finish as a date that's 3 days afterwards

Apparently, this is wrong somewhere:

$finish = start('d-m-Y', strtotime($start. ' + 3 days'));

echo $finish;

Well, start() probably isn't a function...

 

On a similar note, I used some script to successfully change mm-dd-yyyy to Y-m-d.

echo $newdate; works fine.

But POST[$newdate] is not connecting.

Any easy answer?

Did you really name the form field using a date?

 

And while on the subject, after all this DATE work, I opened Firefox using a form with an HTML input type=date. It displayed mm/dd/yyyy to the user, but intuitively echoed yyyy-mm-dd. Is this a benefit of Firefox or HTML? Is it trusted? Reliable? Will the feature work as default in other browsers?

The display format varies but receiving a Y-m-d formatted date is reliable.

Share this post


Link to post
Share on other sites

@Requinix

I did say I was going to avoid the drama, but your one line uninformative respondes make it apparent that you thrive and require drama.

So here we go:

 

No, START is not a function. The name $start was used in the post to simplify the matter and make it obvious to readers (with the exception of Requinix) of what I was trying to accomplish.

Do I need a function?

 

The name of the field (as indicated) is "new date". It is written as one word in all lowercase letters. Got it now???

 

I don't want to nitt-pick, but 4 questions and a single line that might address 3 is pretty impressive from you. Care to elaborate or torch on the 4th portion?

Share this post


Link to post
Share on other sites

phpup - aren't you being rather rude as someone who is seeking help?

 

You posted what is supposedly your code. You made reference to something "start(....)" which is obviously a function. Certainly not a PHP function so we can only assume that you wrote a function named 'start'. Then when questioned about it you get rude.

 

Why don't you stick to ONE problem at a time. Get the answer to that one and you may just learn something that will help you with your next problem.

 

PS - have you bothered to look up the datetime functions in the PHP manual?

Share this post


Link to post
Share on other sites

Rude? No. I think I was rather polite in explaining and clarifying.

Assistance that is helpful is appreciated. But responses that offer no corrections to code I provided and no guidance to resolution are not much help, I'm sure you'd agree.

My research lead me to believe there was a single line of code in PHP that would let me add the days.

I'm not sure what I got inaccurate, and THAT is why I posted.

The second issue is very similar, so insight or correction would be beneficial.

Lastly, of there are people with experience like mine, then answers it comments would be helpful.

Share this post


Link to post
Share on other sites
Posted (edited)

I fully agree with requinix, he posed some serious questions, that may help you solve the problem. By being rude, you achieve nothing.

 

- start() isn't a function (unless you declared it, but somehow it looks exactly like date() which is what requinix was referring to)

- $newdate by name makes us assume it's an actual date thus _POST[$newdate] would mean you used a date as a form field.

 

Instead of pointing your fingers at requinix, you would be best to examine your question first and perhaps formulate it properly so we don't have to guess to what the problem might be. And do something helpful, like posting your actual code so we don't have to consult our magic ball :psychic:.

 

Before you start pointing your fingers at me, that this post didn't contain any helpful assistance, I'll add these:

 

1. What is the value of $start, it's probable that the format used is not recognized by strtotime(). Take a look at http://php.net/manual/en/datetime.formats.php for supported formats.

2. Replace start with date

3. What's the value of $newdate

4. What is the content of $_POST

Edited by ignace

Share this post


Link to post
Share on other sites

Let me provide some assistance since it seems I did not apparently.

 

 $finish = start('d-m-Y', strtotime($start. ' + 3 days'));
 echo $finish;
What happens when you actually RUN this code? Hopefully you have php error checking turned on so that you see the error message it should produce.

 

Of course, by now you have taken my previous advice to reference the PHP manual and have solved your problem using the datetime functions.

Share this post


Link to post
Share on other sites

@ignace (and everyone else)

Thru fortitude and determination I got the code working on my own at 2AM. It may not be perfect, but it's doing what I need it to do.

I woke this morning and saw your reply.

To your credit, much of the problem hinged on your item 2, as I did not realize that the function name DATE was an essential requirement to the code's effectiveness.

Thanks for the effort.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.