Jump to content


Photo

Up all night with DAYS


  • Please log in to reply
7 replies to this topic

#1 phppup

phppup
  • Members
  • PipPipPip
  • Advanced Member
  • 286 posts

Posted 16 May 2018 - 12:53 AM


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?

#2 requinix

requinix
  • Administrators
  • Impoverished Administrator
  • 9,874 posts
  • LocationWA

Posted 16 May 2018 - 01:00 AM

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.
"Basically, I think the general rule of thumb is: if someone really wants the blood that's inside of your body, and they're like a vampire, or a dracula, or some sort of man-squito, then that's probably okay. A dracula and a man-squito are made for removing things like blood and swords from inside your body. That's basically fine. If something wants to get at your blood and they're, say, some kind of murdersaurus, or maybe a really big frog, that's where the problems start to arise. A really big frog is not made for removing blood, and your blood knows this, which is why it is so vehement about wanting to stay in your body instead of coming out. Unfortunately this will not deter a really big frog because a really big frog is full of things like prizes, and value, and quite a lot of hatred, and it would really rather like to replace any and all of those things with your blood, and basically by any means possible." --slumbermancer

#3 phppup

phppup
  • Members
  • PipPipPip
  • Advanced Member
  • 286 posts

Posted 16 May 2018 - 01:49 AM

@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?

#4 ginerjm

ginerjm
  • Members
  • PipPipPip
  • Handball player
  • 4,194 posts
  • LocationVoorheesville NY

Posted 16 May 2018 - 03:01 AM

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?
JG
PS - If you're posting here you should be using:
        error_reporting(E_ALL);
        ini_set('display_errors', '1');

at the top of ALL php code while you develop it!

#5 phppup

phppup
  • Members
  • PipPipPip
  • Advanced Member
  • 286 posts

Posted 16 May 2018 - 03:41 AM

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.

#6 ignace

ignace
  • Moderators
  • Now mod flavored
  • 6,439 posts

Posted 16 May 2018 - 09:38 AM

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/manua...ime.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, 16 May 2018 - 09:44 AM.


#7 ginerjm

ginerjm
  • Members
  • PipPipPip
  • Handball player
  • 4,194 posts
  • LocationVoorheesville NY

Posted 16 May 2018 - 01:11 PM

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.
JG
PS - If you're posting here you should be using:
        error_reporting(E_ALL);
        ini_set('display_errors', '1');

at the top of ALL php code while you develop it!

#8 phppup

phppup
  • Members
  • PipPipPip
  • Advanced Member
  • 286 posts

Posted 16 May 2018 - 01:14 PM

@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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users