I'm about to pull my hair out people. I've got a form where people select a day and a month from the dropdown menu, and the current year would automatically get concatenated.
On the server I've got this:
$received = date("Y")."-".$_POST['month']."-".$_POST['day'];
$date = strtotime($received);
$newformat = date('Y F j',$date);
echo $newformat;
Let's say $_POST['month'] == 'April'
and $_POST['day'] == '5'
The output always comes out like this:
2013 April 1
(ie the day defaults to 1).
Interestingly if $_POST['day'] == '24'
then the output is:
2013 April 2
It's as though it just looks at the first digit.. Any ideas would be greatly appreciated!
Is your issue that your "Month" variable is a string instead of an integer, but you are putting it in the date as if it's an integer? 2013-April-5
... Try just putting in a 4
instead of April
.
Update
To answer your question, you can have your client updated to have options like <option value="1">January</option>
, or update your PHP to process it like:
<? $received = $_POST['month']." ".$_POST['day']." ".date("Y");
$date = strtotime($received);
$newformat = date('Y F j',$date);
echo $newformat; ?>
I think that will work.
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加