I really tried everything, I get my date from date picker like this : 05/10/2016
then I replaced the / with - . used strtotime but i always get 01-1-1970.
this is my code:
if (isset($_POST['CampaignName']) && isset($_POST['CampaginBudget']) && isset($_POST['start_date']) && isset($_POST['end_date']) && $email )
{
// receiving the post params
$CampaignName= $_POST['CampaignName'];
$CampaignBudget = $_POST['CampaginBudget'];
$start_date= str_replace('/', '-', $_POST['start_date']);
$end_date = explode('/', $end_date);
$start_date = date('Y-m-d', strtotime($start_date));
$end_date = date('Y-m-d', strtotime(implode('-', strtotime($end_date))));
//$end_date = date('Y-m-d', strtotime($end_date2));
echo $start_date; echo $end_date;
edit : startdate works fine but end date has problem. even when they are exactly the same
html code:
Campaign Duration :<input type="text" name="start_date" class="form-control" id="datetimepicker" placeholder="mm/dd/yyyy"/ required> <span> TO </span> <input type="text" name="end_date" class="form-control" id="datetimepicker2" placeholder="mm/dd/yyyy"/ required>