last day (15 days later) » 

04:33
0
Q: inserting date values are always 0000-00-00 in php

jericoGood day! I am trying to insert date to a mysql table. The table I created is as fallow: I am inserting the data with the following function statement: if (isset($_POST['setSchedule'])) { $data->set_Schedule($test, $conn); echo"<script>location.replace('EvaluationSch...

date('m-d-Y H:i:s') is wrong you should rather use date('Y-m-d H:i:s').Why? because the default Mysql DATETIME format is like yyyy-mm-dd 24h:mm:ss
the value on Evaluation_ScheduleFrom is still 0 but in the Evaluation_ScheduleTo table the value is 1970-01-01 even though I pick 08/21/2018
Oh didn't see that it was a DATE datatype column use date('Y-m-d') also need to convert the $_POST variable to a time-stamp first.So you have $subjectID = date( 'Y-m-d',strtotime($_POST['setSchedule']) );
How to convert it ?
Using strtotime()
04:33
It works! But the value in Evaluation_ScheduleFrom is 1970-01-01 and in Evaluation_ScheduleTo is 2018-08-22 not the same as I pick the date..
Hi Viney..
Hi
please echo $_POST['setSchedule'] and see what it returns
05:03
it says
Notice: Undefined variable: test in C:\xampp\htdocs\capstone\admin\guidance\EvaluationSchedule_set.php on line 8
05:15
$date1 = $_REQUEST['date'];
echo date('Y-m-d', strtotime($date1));
How to insert that on my code
$setSchedule = date('Y-m-d',strtotime($_POST['setSchedule']));
05:33
echo $setSchedule
1970-01-01
echo $_POST['setSchedule']
It says 1970-01-01
well this means the problem is on your frontend
19
Q: PHP date showing '1970-01-01 ' after conversion

AssamGuyI have a form in which date format is dd/mm/yyyy . For searching database , I hanverted the date format to yyyy-mm-dd . But when I echo it, it showing 1970-01-01 . The PHP code is below: $date1 = $_REQUEST['date']; echo date('Y-m-d', strtotime($date1)); Why is it happening? How can I form...

wee have the same problem but I don't know how to apply that to my codes
05:47
Which datepicker are you using? when you select a date and submit php should receive the it like 08/19/2018 then only strtotime can work properly but as you've mentioned you are receiving it like 1970-01-01 that's why you need to check your datepicker first
05:59
<input type"date">
<input class="form-control col-sm-8" type="date" id="datepicker1" placeholder="Enter Student ID" name="lastSchedule" autocomplete="off">
06:38
then why are you using $_POST['setSchedule'] instead of $_POST['lastSchedule']?

last day (15 days later) »