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 Link to comment https://forums.phpfreaks.com/topic/249282-date-from-_get/ 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); Link to comment https://forums.phpfreaks.com/topic/249282-date-from-_get/#findComment-1280045 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.