phppup Posted May 16, 2018 Share Posted May 16, 2018 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? Quote Link to comment Share on other sites More sharing options...
requinix Posted May 16, 2018 Share Posted May 16, 2018 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. Quote Link to comment Share on other sites More sharing options...
phppup Posted May 16, 2018 Author Share Posted May 16, 2018 @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? Quote Link to comment Share on other sites More sharing options...
ginerjm Posted May 16, 2018 Share Posted May 16, 2018 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? Quote Link to comment Share on other sites More sharing options...
phppup Posted May 16, 2018 Author Share Posted May 16, 2018 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. Quote Link to comment Share on other sites More sharing options...
ignace Posted May 16, 2018 Share Posted May 16, 2018 (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 . 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 May 16, 2018 by ignace Quote Link to comment Share on other sites More sharing options...
ginerjm Posted May 16, 2018 Share Posted May 16, 2018 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. Quote Link to comment Share on other sites More sharing options...
phppup Posted May 16, 2018 Author Share Posted May 16, 2018 @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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.