ebolt007 Posted October 17, 2011 Share Posted October 17, 2011 Ok, I have a form with a field that is a datre currently set to use the follwing date; $main_date = date("l, F j, Y", $cur_date_timestamp); and my input area is as follows. echo "<form action=\"mobile_index.php\" enctype=\"multipart/form-data\" method=\"get\" name=\"update_form\">\n"; echo "<input type='text' size=\"26\" name='date' class=\"mobile_input\" value='$main_date' onKeyPress=\"return submitenter(this,event)\">\n"; echo "</form>\n"; Now when this submits I get mobile_index.php?date=Monday%2C+October+17%2C+2012 in my url I need to get that date tho and use it as a variable so I can break it apart into 3 parts like. $main_date2 = $_GET['date']; $main_date = date("M-d-Y", $main_date2); $cur_day = date("d", $main_date); $cur_month = date("n", $main_date); $cur_year = date("Y", $main_date); Is there anyway to do this? I get Warning: date() expects parameter 2 to be long, string given in /home/admin/public_html/mobile_index.php on line 15 Because the date isn't an integer variable PHP understands, because line 15 is $main_date = date("M-d-Y", $main_date2); How do I break the $main_date2 into yeear, month and day so I can work with it? Thanks Quote Link to comment Share on other sites More sharing options...
Psycho Posted October 17, 2011 Share Posted October 17, 2011 $main_date_ts = strtotime($_GET['date']); //Create timestamp $main_date = date("M-d-Y", $main_date_ts); $cur_day = date("d", $main_date_ts); $cur_month = date("n", $main_date_ts); $cur_year = date("Y", $main_date_ts); 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.